Skip to content

Commit

Permalink
Remove unneeded check in AsyncToSync.
Browse files Browse the repository at this point in the history
current_executor is set unconditionally in the same block above.
  • Loading branch information
carltongibson committed Oct 9, 2024
1 parent 6e1ff91 commit 63ea9e9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions asgiref/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,17 @@ def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R:
loop_future = loop_executor.submit(
self._run_event_loop, loop, awaitable
)
if current_executor:
# Run the CurrentThreadExecutor until the future is done
current_executor.run_until_future(loop_future)
# Run the CurrentThreadExecutor until the future is done.
current_executor.run_until_future(loop_future)
# Wait for future and/or allow for exception propagation
loop_future.result()
else:
# Call it inside the existing loop
self.main_event_loop.call_soon_threadsafe(
self.main_event_loop.create_task, awaitable
)
if current_executor:
# Run the CurrentThreadExecutor until the future is done
current_executor.run_until_future(call_result)
# Run the CurrentThreadExecutor until the future is done.
current_executor.run_until_future(call_result)
finally:
# Clean up any executor we were running
if loop is not None:
Expand Down

0 comments on commit 63ea9e9

Please sign in to comment.