remote_actor: cleanly catch exceptions while fetching actors
This commit is contained in:
parent
e0d633b861
commit
69dfb04131
|
@ -1,3 +1,4 @@
|
||||||
|
import logging
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from . import CONFIG
|
from . import CONFIG
|
||||||
from .http_debug import http_debug
|
from .http_debug import http_debug
|
||||||
|
@ -15,7 +16,13 @@ async def fetch_actor(uri, force=False):
|
||||||
if uri in ACTORS and not force:
|
if uri in ACTORS and not force:
|
||||||
return ACTORS[uri]
|
return ACTORS[uri]
|
||||||
|
|
||||||
async with aiohttp.ClientSession(trace_configs=[http_debug()]) as session:
|
try:
|
||||||
async with session.get(uri, headers={'Accept': 'application/activity+json'}) as resp:
|
async with aiohttp.ClientSession(trace_configs=[http_debug()]) as session:
|
||||||
ACTORS[uri] = (await resp.json(encoding='utf-8', content_type=None))
|
async with session.get(uri, headers={'Accept': 'application/activity+json'}) as resp:
|
||||||
return ACTORS[uri]
|
if resp.status_code != 200:
|
||||||
|
return None
|
||||||
|
ACTORS[uri] = (await resp.json(encoding='utf-8', content_type=None))
|
||||||
|
return ACTORS[uri]
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('Caught %r while fetching actor %r.', e, uri)
|
||||||
|
return None
|
||||||
|
|
Loading…
Reference in a new issue