Skip to content

Commit

Permalink
handle cases where it's not possible to get the current event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Aug 19, 2019
1 parent 8002e74 commit 32c0cd4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion isogeo_pysdk/api/routes_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,16 @@ def search(
}

# launch async searches
loop = asyncio.get_event_loop()
try:
loop = asyncio.get_event_loop()
except RuntimeError as e:
logger.warning(
"Async get loop failed. Maybe because it's already executed in a separated thread.",
e,
)
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

future_searches_concatenated = asyncio.ensure_future(
self._search_metadata_asynchronous(
total_results=total_results, **search_params
Expand Down

0 comments on commit 32c0cd4

Please sign in to comment.