try: stacklim = int(a)*1024L except ValueError: log.die("Bad stack limit '%s'" % a) elif o == '-M': threadmax = int(a) if threadmax < 0: threadmax = 0 else: log.die("Chris failed to properly parse option: "+o) if len(args) != 1: usage() # We switch to syslog immediately on startup if told to; all further # errors, even fatal ones, may emerge through there. if usesyslog: log.usesyslog() # Set RLIMIT_STACK. Thanks, glibc! if stacklim is not None: res = proc.setstacklim(stacklim) if res: log.error("Could not set stacklimit %s: %s" % (stacklim, res)) # Portnanny only uses threads to deal with things that stall at the # operating system level; they don't do any expensive Python-level # operations. Because Python is single-threaded at the interpreter # bytecode level, we effectively want just voluntary preemption at # stall points; switching back and forth between active threads at # other times is somewhere between pointless and counterproductive. # To approximate this, we tell Python to check for thread switches # (and as a side effect, signals) only very, very infrequently. # The number here is arbitrary but large.
def testSyslogNulls(self): "Test that attempting to syslog NULLs does not explode." log.usesyslog() log.warn("Should have these \0 nulls substituted \0 yep.")