Last active
December 6, 2019 16:49
-
-
Save schipiga/223091e5115f3cbee09fa5fc0b54dd87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PoolManager: # already existing class | |
def start(self): | |
self.init_signals() # added by me | |
self.worker_manager.create_workers() | |
# all below added by me | |
def init_signals(self): | |
if hasattr(signal, 'SIGCHLD'): | |
signal.signal(signal.SIGCHLD, handle_chld) | |
def handle_chld(signum, frame): | |
reap_workers() | |
def reap_workers(): | |
try: | |
while True: | |
wpid, status = os.waitpid(-1, os.WNOHANG) | |
if not wpid: | |
break | |
except OSError as e: | |
if e.errno != errno.ECHILD: | |
raise e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment