[spambayes-dev] stopping pop3proxy

Richie Hindle richie at entrian.com
Mon Aug 25 14:15:13 EDT 2003


[Mark]
> stop() appears dangerous - remember it is called 
> asynchronously, so another thread could be doing almost 
> anything.  What we really need is a trigger to tell the main 
> loop to stop, and the save should be done as that loop terminates.

[Tony]
> I understand what you're saying, but I don't know how to do this -
> hopefully Richie does.  The closest I can think of is that stop() needs
> to call stop_when_done() on each of the BayesProxy objects, and then
> wait until they have all stopped (I don't know how to check this).  Then
> save then return.
> 
> Richie - any advice?

What needs to be done is to refuse all new connections (or rather accept
them but push() back an error message and call close_when_done(),
according to whether some flag, probably state.isShuttingDown or similar),
then exit when all current connections complete (close_when_done is
per-connection, so it's not what we want - the connections will close
anyway).  I think the best way to do this is to call sys.exit() when
BayesProxy.close() is called and state.activeSessions goes to zero with
state.isShuttingDown set.  I'll try to have a look at this - if anybody
else wants to look at it, let me know so we don't duplicate the work.

> Also in terms of stopping pop3proxy, on my fiance's computer pop3proxy
> is running all the time so that she doesn't have to know how to start &
> stop it when checking for mail (it's too old for pop3proxy_service).
> This works fine, except that when she shuts down Windows, it comes up
> with a "can't shut this program down" message (it does terminate it
> after a delay, but it's annoying).  Is there some way that we can handle
> this?  I presume Windows sends a sigterm or something to the
> application?  Would other OSs do exactly the same thing?

Windows sends a message to all top-level windows on shutdown, but the
pop3proxy has no windows.  Oddly, my XP box shuts down fine, with no
warnings - I can't explain that... Mark?

-- 
Richie Hindle
richie at entrian.com




More information about the spambayes-dev mailing list