[Oval-devel] CTRL+C handling in server

Pavel Vinogradov Pavel.Vinogradov at nixdev.net
Wed Oct 17 06:37:20 UTC 2007


  During last weekend i was work on bug about stopping oval-server on
keyboard interrupt from console (aka CTRL+C bug).

  I was implement and commit proper handling of CTRL+C (which translated in
KeyboardException inside Python) in main thread of oval-server. But python
don't have api to stop execution of child thread, therefore i implement
child threads with:

while self.__status:
  <handle>
  <sleep>

  In case of syncThread i'm use sleep with timeout, but in httpThread used
call to socket.accept () and thread is blocked on this call until receive
request from client. And i can't stop httpThread in clear way.

  Reading google and some experiments give me three version of stopping http
thread:
1. mainThread on KeyboardException send yourself HUP or KILL signal and this
signal kills all thread.
2. Use sockets timeouts. With timeouts accept call was interrupted after
some time. But in this case i must rewrite some methods of parent HttpServer
class.
3. Emulate client connection to httpThread from mainThread.

  I think that second choice is a best way, but first simplest. Any suggest
or any approach?

-- 
Pavel Vinogradov
NixDev.Net, Linux Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/oval-devel/attachments/20071017/e35f5e49/attachment.htm 


More information about the Oval-devel mailing list