From e0d633b861f98ee532af9737c3ddb837cee14a49 Mon Sep 17 00:00:00 2001 From: kaniini Date: Sun, 18 Nov 2018 22:05:41 +0000 Subject: [PATCH] actor: cleanly catch exceptions while delivering messages --- relay/actor.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/relay/actor.py b/relay/actor.py index 2d4b5b1..1aebe7f 100644 --- a/relay/actor.py +++ b/relay/actor.py @@ -93,12 +93,15 @@ async def push_message_to_actor(actor, message, our_key_id): logging.debug('%r >> %r', inbox, message) - async with aiohttp.ClientSession(trace_configs=[http_debug()]) as session: - async with session.post(inbox, data=data, headers=headers) as resp: - if resp.status == 202: - return - resp_payload = await resp.text() - logging.debug('%r >> resp %r', inbox, resp_payload) + try: + async with aiohttp.ClientSession(trace_configs=[http_debug()]) as session: + async with session.post(inbox, data=data, headers=headers) as resp: + if resp.status == 202: + return + resp_payload = await resp.text() + logging.debug('%r >> resp %r', inbox, resp_payload) + except Exception as e: + logging.info('Caught %r while pushing to %r.', e, inbox) async def follow_remote_actor(actor_uri):