1 Sep 2006 01:26
Re: Organizing a Quixote/Durus multiprocess application
Mike Orr <sluggoster <at> gmail.com>
2006-08-31 23:26:34 GMT
2006-08-31 23:26:34 GMT
Here's what I've got so far. Does it look reasonable? I first divert sys.stdout and sys.stderr to a logfile unless envvar "NO_LOG" is set. This will be used by all subprocesses. I don't want some output sent to the console or swallowed up depending on where the exception hits. Then I fork and (in the child) start the Durus server for the sessions db, and (in the parent) start the SCGI server. I catch KeyboardInterrupt in both cases to avoid a traceback in the log file. I'm using None for both the Quixote error log and the Durus error log to prevent those packages from redirecting it further. It took a while to get the file ownerships and umask correct, but I finally got it working as user 'apache' from the command line. But if I start it as a daemon and then stop it, it doesn't kill the Durus server. That must be because it's using SIGTERM instead of SIGINT. I added some code to kill it manually if it's still running, but that doesn't help. I may switch to a TCP socket if it gets too frustrating managing the Unix socket, but I don't think that will help the current problem Another issue is getting rid of Durus's "sys.stdout already customized. sys.stderr already customized." messages in the log file. I set logginglevel to 101 but that doesn't help because the messages are sent before that gets set. I may replace durus.logging.direct_output to get rid of them. Another issue is in scgi_server. I sometimes get a KeyError on "self.reap_children(self.children[pid])". I assume that means the SCGI subprocess has already died, because one of them gave a(Continue reading)
.
> If I remember correctly, your database is cycle-free,
> so the gc garbage collector probably isn't doing anything
> for you, or causing trouble. If it were, you
> could call gc.disable().
"gc.disable()" disables the garbage collection of cycles, but this is
not an issue here. I'm talking about the reference counter when I say
"garbage collection".
I am testing a WeakValueDictionary subclass implementing my first
suggestion: take note of the deleted objects, but keep them in the
dictionary until "cache.shrink()" calls "dictionary.shrink()".
Would you be interested in the patch?. No noticeable performance hit.
We only need to add a "dictionary.shrink()" in "cache.shrink()". The
RSS Feed