[spambayes-dev] Re: [Spambayes-checkins] spambayes/scriptssb_server.py, 1.15, 1.16

Tony Meyer tameyer at ihug.co.nz
Wed Dec 31 16:45:55 EST 2003


> This edit keeps appearing and disappearing.  Mark removed 
> that line in order to fix the fact that none of sb_server's 
> command line arguments worked.  Tony has now put it back in 
> order to fix a restart problem, which has once again broken 
> all the command line arguments.

Opps.  Sorry, I must try and pay more attention...

> Does anyone have a clear idea of what each of prepare(), 
> State.__init__(), State.init(), and State.prepare() are all 
> intended to do?  I think the command line option code needs 
> to be inserted somewhere into one of them, but I'm not 100% 
> sure what each of them is for.

I'm not sure about intent, but this is what they currently do:

__init__(): calls init()
init():     opens the log file
            sets up the list of servers/ports
            loads options from configuration file
            resets statistics
prepare():  opens mutex
(and in calling createWorkers())
            opens db
            opens the corpora
            creates the trainers

Should init() be only done once for every time that sb_server is run, and
prepare() each time it is started/stopped?  In that case it should be:

__init__(): calls init()
init():     opens the log file
            loads options from configuration file
            resets statistics
prepare():  opens mutex
            sets up the list of servers/ports
(and in calling createWorkers())
            opens db
            opens the corpora
            creates the trainers

This makes prepare() a kind of anti-close().  This is probably the fix I
should have applied - moving setting up the list of servers/ports to
prepare() instead of calling init() again.  It needs to be done *sometime*
after close(), though, and before the call to createWorkers().  Whether the
log file and statistics should be reset on start/stop, I don't know, but I
suspect not.  This would mean that the command-line code could be anywhere
between __init__() and prepare().

+1 to docstrings for init() and prepare(), though :)

=Tony Meyer




More information about the spambayes-dev mailing list