fix: log exception if we can't get the event loop

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2341>
This commit is contained in:
jo 2023-01-27 17:37:41 +01:00
parent c793799161
commit 96bbe2131a
1 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import asyncio
import functools
import logging
import aiohttp
import pyld.documentloader.requests
@ -10,6 +11,8 @@ from rest_framework.fields import empty
from . import contexts
logger = logging.getLogger(__name__)
def cached_contexts(loader):
functools.wraps(loader)
@ -282,7 +285,8 @@ class JsonLdSerializer(serializers.Serializer):
if dereferenced_ids:
try:
loop = asyncio.get_event_loop()
except RuntimeError:
except RuntimeError as exception:
logger.debug(exception)
loop = asyncio.new_event_loop()
references = self.context.setdefault("references", {})
loop.run_until_complete(