Created
July 20, 2016 18:02
-
-
Save notmyname/fce34c093df2489582375e50bad998a5 to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py | |
index 8ee12c8..6b211a3 100644 | |
--- a/swift/common/wsgi.py | |
+++ b/swift/common/wsgi.py | |
@@ -952,12 +952,20 @@ def run_wsgi(conf_path, app_section, *args, **kwargs): | |
with Timeout(loop_timeout, exception=False): | |
try: | |
- pid, status = green_os.wait() | |
- if os.WIFEXITED(status) or os.WIFSIGNALED(status): | |
- strategy.register_worker_exit(pid) | |
- except OSError as err: | |
- if err.errno not in (errno.EINTR, errno.ECHILD): | |
- raise | |
+ try: | |
+ pid, status = green_os.wait() | |
+ if os.WIFEXITED(status) or os.WIFSIGNALED(status): | |
+ strategy.register_worker_exit(pid) | |
+ except OSError as err: | |
+ if err.errno not in (errno.EINTR, errno.ECHILD): | |
+ raise | |
+ if err.errno == errno.ECHILD: | |
+ # If there are no children at all (ECHILD), then | |
+ # there's nothing to actually wait on. We sleep | |
+ # for the loop_timeout to avoid a tight CPU spin | |
+ # and still are able to catch any KeyboardInterrupt | |
+ # events that happen. | |
+ sleep(loop_timeout) | |
except KeyboardInterrupt: | |
logger.notice('User quit') | |
running[0] = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment