Skip to content

Commit

Permalink
Do not try to install signal handler if unsupported (Fixes #199)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeeringPhil authored and miguelgrinberg committed Oct 7, 2020
1 parent e6fb095 commit c0a1c28
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions engineio/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,14 @@ async def connect(self, url, headers=None, transports=None,
global async_signal_handler_set
if not async_signal_handler_set and \
threading.current_thread() == threading.main_thread():
asyncio.get_event_loop().add_signal_handler(signal.SIGINT,
async_signal_handler)
async_signal_handler_set = True

try:
asyncio.get_event_loop().add_signal_handler(
signal.SIGINT, async_signal_handler)
async_signal_handler_set = True
except NotImplementedError: # pragma: no cover
self.logger.warning('Signal handler is unsupported')

if self.state != 'disconnected':
raise ValueError('Client is not in a disconnected state')
valid_transports = ['polling', 'websocket']
Expand Down

0 comments on commit c0a1c28

Please sign in to comment.