SimpleXMLRPCServer interruptable?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu Dec 6 21:43:54 EST 2007
En Thu, 06 Dec 2007 13:11:09 -0300, Bret <bret.wortman at gmail.com> escribió:
> For completeness, what I ended up doing is this:
>
> server = SimpleXMLRPCServer((host, port))
> server.socket.settimeout(0.1)
>
> ServerWrapper became:
>
> def ServerWrapper():
> while True:
> try:
> server.handle_request()
> if self.done.isSet():
> break
> except timeout:
> pass
>
> And that seems to do the trick! Giving the socket a timeout allows me
> to check the Event more frequently and catch the change within a
> reasonable time.
Remember that the timeout applies to *all* socket operations; what if the
XML request requires more than 0.1s to read?
If handling large requests is more important than the delay at shutdown
time, consider raising that value.
--
Gabriel Genellina
More information about the Python-list
mailing list