Skip to content

Commit

Permalink
Client: attempt to switch to synchronous mode when existing event loo…
Browse files Browse the repository at this point in the history
…p is detected (#1940)
  • Loading branch information
ml-evs authored Jan 17, 2024
1 parent 6f76250 commit b646a0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions optimade/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ def _execute_queries(
A mapping from base URL to `QueryResults` for each queried API.
"""

if self.use_async:
# Check for a pre-existing event loop (e.g. within a Jupyter notebook)
# and use it if present
Expand All @@ -680,9 +679,10 @@ def _execute_queries(
"Detected a running event loop, cannot run in async mode."
)
self._progress.print(
"Detected a running event loop (e.g., Jupyter, pytest). Trying to use nest_asyncio."
"Detected a running event loop (e.g., Jupyter). Attempting to switch to synchronous mode."
)
self.use_async = False
self._http_client = requests.Session
except RuntimeError:
event_loop = None

Expand Down

0 comments on commit b646a0a

Please sign in to comment.