narrow bare except around super().initialize() in AsyncioSelectorLoop#3642
Open
HrachShah wants to merge 1 commit into
Open
narrow bare except around super().initialize() in AsyncioSelectorLoop#3642HrachShah wants to merge 1 commit into
HrachShah wants to merge 1 commit into
Conversation
The bare 'except Exception:' wrapped super().initialize(**kwargs) in the asyncio-backed IOLoop initialize(), with a fallback that closes the newly-created asyncio event loop if the super initialize failed (taking ownership of the loop was not successful). The narrow set covers the actual failures of IOLoop initialize: OSError (file descriptor limit reached when opening the epoll/kqueue/select fd, can't bind, can't open /dev/null for stderr redirection), RuntimeError (asyncio loop already running, or a conflicting call to asyncio.set_event_loop), ValueError (an explicit invalid arg check inside the super) and TypeError (an unexpected kwarg passed through **kwargs from a downstream caller that the asyncio loop's initializer doesn't accept). KeyboardInterrupt and SystemExit are BaseException and were being swallowed by the bare 'except Exception' — narrowing lets a Ctrl-C during IOLoop initialize propagate immediately to whatever the caller of AsyncioSelectorLoop.initialize was, instead of being caught, running the loop.close() fallback, and re-raised as a new chained exception.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
narrow bare except around super().initialize() in AsyncioSelectorLoop
The bare 'except Exception:' wrapped super().initialize(**kwargs) in the
asyncio-backed IOLoop initialize(), with a fallback that closes the
newly-created asyncio event loop if the super initialize failed (taking
ownership of the loop was not successful). The narrow set covers the
actual failures of IOLoop initialize: OSError (file descriptor limit
reached when opening the epoll/kqueue/select fd, can't bind, can't
open /dev/null for stderr redirection), RuntimeError (asyncio loop
already running, or a conflicting call to asyncio.set_event_loop),
ValueError (an explicit invalid arg check inside the super) and
TypeError (an unexpected kwarg passed through **kwargs from a
downstream caller that the asyncio loop's initializer doesn't accept).
KeyboardInterrupt and SystemExit are BaseException and were being
swallowed by the bare 'except Exception' — narrowing lets a Ctrl-C
during IOLoop initialize propagate immediately to whatever the caller
of AsyncioSelectorLoop.initialize was, instead of being caught,
running the loop.close() fallback, and re-raised as a new chained
exception.