SocketServer and timers
alf
ask at me
Tue Aug 8 22:03:58 EDT 2006
bryanjugglercryptographer at yahoo.com wrote:
> alf wrote:
>
>>I have one thread app using SocketServer and use server_forever() as a
>>main loop. All works fine, but now I need certain timer checking let's
>>say every 1 second something and stopping the main loop. So questions are:
>> -how to stop serve_forever
>
>
> Override serve_forever() and replace "while 1:" with something like
> "while self.continue_flag:".
>
>
>> -how to implement timers
>
>
> You could override get_request(), and use select.select() to wait for
> either the socket to become readable (so the accept() won't block), or
> a timeout to expire. If you are not already, use the threading or
> forking
> mixin so that the request handler won't stop everthing if it blocks.
>
>
thx for a suggestion, will try it out ...
More information about the Python-list
mailing list