SimpleXMLRPCServer interruptable?

Bret bret.wortman at gmail.com
Mon Dec 10 13:40:02 EST 2007


On Dec 6, 7:43 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> En Thu, 06 Dec 2007 13:11:09 -0300, Bret <bret.wort... 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

Good point.  Thanks!



More information about the Python-list mailing list