To me privadi na myslenku, kdyz vidim ten try, jestli nechytas vyjimku
SystemExit.
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()
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Lumír Jasiok
Sent: Wednesday, December 17, 2008 2:26 PM
To: Konference PyCZ
Subject: [python] Problem s forkujicim serverem a SIGTERM signalem
Dobry den,
potreboval bych poradit s nasledujicim problemem. Mam napsany
jednoduchy
forkujici TCP/IP server. Server jako takovy funguje, child procesy se
vytvareji i ukoncuji korektne, jediny probleme mam s ukoncenim parent
procesu v okamziku, kdy z (napriklad shellu) zavolam signal SIGTERM.
Mam
osetreno zachyceni signalu a funkci, ktera zajisti, ze se pocka na
ukonceni vsech child procesu a pak by se mel ukoncit i parent proces
pomoci sys.exit(0). To se ale nestane, parent proces (server) se
neukonci, ale skoci do nadrazene while smycky a dale ceka na spojeni a
je schopen obsluhovat prichozi spojeni. Relevantni kod:
_______________________________________________
Python mailing list
[email protected]
http://www.py.cz/mailman/listinfo/python
--
------------------------------------------------------------------------
*Leoš Pol*
senior programátor Lide.cz
*Seznam.cz a.s.*
Business Park, budova B
Londýnské náměstí 2
639 00 Brno
tel: +420 543 533 073
gsm: +420 777 901 087
email: [email protected] <mailto:[email protected]>
www: http://www.seznam.cz
_______________________________________________
Python mailing list
[email protected]
http://www.py.cz/mailman/listinfo/python