Skip to content

Commit

Permalink
Added leniency to the code (#33)
Browse files Browse the repository at this point in the history
Co-authored-by: ceprio <c.git@pronovost.net>
  • Loading branch information
ceprio and ceprio authored Apr 22, 2021
1 parent b65b91e commit 383e8c1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions webruntime/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,21 @@ def __init__(self, **kwargs):
atexit.register(self.close)

# Increase chance of closing runtime when Python is forced to stop
signal.signal(signal.SIGTERM, self.close)
signal.signal(signal.SIGINT, self.close)

try:
signal.signal(signal.SIGTERM, self.close)
except ValueError as e: # Cannot use signal.signal outside of main thread
if str(e) != 'signal only works in main thread':
raise
else:
pass # Continue as it will still work on some browser (like Chrome)
try:
signal.signal(signal.SIGINT, self.close)
except ValueError as e: # Cannot use signal.signal outside of main thread
if str(e) != 'signal only works in main thread':
raise
else:
pass # Continue as it will still work on some browser (like Chrome)

self._exe = None
self._version = None
self._proc = None
Expand Down

0 comments on commit 383e8c1

Please sign in to comment.