Skip to content

Commit 6692f3d

Browse files
authored
Merge pull request #1014 from cderici/remove-signal-handler-installs
#1014 #### Description In #1010 it's reported that running pylibjuju in an off-main thread blows up the `add_signal_handler` (for a good reason). Also per the discussion in the #1011 about signal handlers, this PR removes the code that installs signal handlers to the event loop at the connection creation. See [my comment](#1011 (comment)) in #1011 for details about reasoning. Fixes #1010
2 parents 32ce250 + c6af97a commit 6692f3d

2 files changed

Lines changed: 1 addition & 11 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ run-unit-tests: lint .tox
2424
tox -e py3
2525

2626
.PHONY: run-integration-tests
27-
run-unit-tests: lint .tox
27+
run-integration-tests: lint .tox
2828
tox -e integration
2929

3030
.PHONY: run-all-tests

juju/client/connection.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import json
66
import logging
77
import ssl
8-
import signal
98
import urllib.request
109
import weakref
1110
from http.client import HTTPSConnection
@@ -425,10 +424,6 @@ def _exit_tasks():
425424
for task in jasyncio.all_tasks():
426425
task.cancel()
427426

428-
loop = jasyncio.get_running_loop()
429-
for sig in (signal.SIGINT, signal.SIGTERM):
430-
loop.add_signal_handler(sig, _exit_tasks)
431-
432427
return (await websockets.connect(
433428
url,
434429
ssl=self._get_ssl(cacert),
@@ -473,11 +468,6 @@ async def close(self, to_reconnect=False):
473468
if self.proxy is not None:
474469
self.proxy.close()
475470

476-
# Remove signal handlers
477-
loop = jasyncio.get_running_loop()
478-
for sig in (signal.SIGINT, signal.SIGTERM):
479-
loop.remove_signal_handler(sig)
480-
481471
async def _recv(self, request_id):
482472
if not self.is_open:
483473
raise websockets.exceptions.ConnectionClosed(0, 'websocket closed')

0 commit comments

Comments
 (0)