4 from .http_debug import http_debug
6 from cachetools import TTLCache
9 CACHE_SIZE = CONFIG.get('cache-size', 16384)
10 CACHE_TTL = CONFIG.get('cache-ttl', 3600)
12 ACTORS = TTLCache(CACHE_SIZE, CACHE_TTL)
15 async def fetch_actor(uri, force=False):
16 if uri in ACTORS and not force:
20 async with aiohttp.ClientSession(trace_configs=[http_debug()]) as session:
21 async with session.get(uri, headers={'Accept': 'application/activity+json'}) as resp:
22 if resp.status != 200:
24 ACTORS[uri] = (await resp.json(encoding='utf-8', content_type=None))
26 except Exception as e:
27 logging.info('Caught %r while fetching actor %r.', e, uri)