Skip to content

Commit 72a0c4f

Browse files
authored
Merge pull request #658 from cderici/asyncio-exception-handling
#658 #### Description Exceptions that happen when a coroutine is being destroyed are ignored, but they cause backround noise such as "Exception ignored in coroutine ..." exceptions etc. This change tries to propogate the exceptions so that the asyncio base handler itself can ignore the exception as an attempt to get rid of that exception ignored noise in test outputs etc. Should fix #657 #### QA Steps No such `Exception ignored in coroutine ...` output in tests. QAing this is a little weird, because the background exception (that is ignored by the GC by design) is an intermittent one. #### Notes & Discussion
2 parents 6c5255b + f7552be commit 72a0c4f

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

juju/client/connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ async def _debug_logger(self):
512512
# be cancelled by the reconnect and we don't want the reconnect
513513
# to be aborted half-way through
514514
jasyncio.ensure_future(self.reconnect())
515-
return
515+
raise
516516
except Exception as e:
517517
log.exception("Error in debug logger : %s" % e)
518518
jasyncio.create_task(self.close())
@@ -539,7 +539,7 @@ async def _receiver(self):
539539
# be cancelled by the reconnect and we don't want the reconnect
540540
# to be aborted half-way through
541541
jasyncio.ensure_future(self.reconnect())
542-
return
542+
raise
543543
except Exception as e:
544544
log.exception("Error in receiver")
545545
# make pending listeners aware of the error
@@ -576,7 +576,7 @@ async def _do_ping():
576576
# The connection has closed - we can't do anything
577577
# more until the connection is restarted.
578578
log.debug('ping failed because of closed connection')
579-
pass
579+
raise
580580

581581
async def rpc(self, msg, encoder=None):
582582
'''Make an RPC to the API. The message is encoded as JSON

juju/jasyncio.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def _task_result_exp_handler(task, task_name=task_name, logger=logger):
6565
try:
6666
task.result()
6767
except CancelledError:
68-
pass
68+
raise
6969
except websockets.exceptions.ConnectionClosed:
70-
return
70+
raise
7171
except Exception as e:
7272
# This really is an arbitrary exception we need to catch
7373
#
@@ -76,6 +76,7 @@ def _task_result_exp_handler(task, task_name=task_name, logger=logger):
7676
# event_handler, which won't do anything but yell 'Task
7777
# exception was never retrieved' anyways.
7878
logger.exception("Task %s raised an exception: %s" % (task_name, e))
79+
raise
7980

8081
task = create_task(coro)
8182
task.add_done_callback(functools.partial(_task_result_exp_handler, task_name=task_name, logger=logger))

0 commit comments

Comments
 (0)