Skip to content

Commit 21629bb

Browse files
committed
fix: correct _run_async_function
1 parent f52bccc commit 21629bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

vcr/stubs/httpx_stubs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ def _run_async_function(sync_func, *args, **kwargs):
176176
- No event loop exists yet.
177177
"""
178178
try:
179-
asyncio.get_running_loop()
179+
loop = asyncio.get_running_loop()
180180
except RuntimeError:
181181
return asyncio.run(sync_func(*args, **kwargs))
182182
else:
183183
# If inside a running loop, create a task and wait for it
184-
return asyncio.ensure_future(sync_func(*args, **kwargs))
184+
return loop.run_in_executor(None, functools.partial(sync_func, *args, **kwargs))
185185

186186

187187
def _sync_vcr_send(cassette, real_send, *args, **kwargs):

0 commit comments

Comments
 (0)