[python] Problem s forkujicim serverem a SIGTERM signalem

Lumír Jasiok lumir.jasiok na vsb.cz
Středa Prosinec 17 16:00:45 CET 2008


David Michal wrote:
> Ja teda neumim vysvetlit proc nejde exit ale co to zkusit takhle:
>
> sysexit = False
>
> def cleanup(signal, frame):
>      """Clean up the server before shutdown.
>      """
>      # SIGTERM signal
>      if signal == 15:
>          print "Received SIGTERM signal, waiting for clients
>  termination"
>          while True:
>              # In case that there isn't any active clients
>              if not clients:
>                  break
>          sysexit = True
>
>  # Nadrazena smycka:
>   while not sysexit:
>          # Handle the child temination
>          signal.signal(signal.SIGCHLD,reap)
>  
>          # Catch the SIGTERM signal
>          signal.signal(signal.SIGTERM, cleanup)
>          #signal.pause()
>          try:
>              connection,address = sock.accept()
>
>   
Genialne jednoduche, jednoduse genialni. Funguje.

Diky moc.

Lumir

-- 
 Lumír Jasiok
 VSB-TU Ostrava - Computer centre
 Tel: +420 59 732 3189
 E-mail: lumir.jasiok na vsb.cz
 http://www.vsb.cz
															



Další informace o konferenci Python