Skip to content

Commit 7181feb

Browse files
committed
Remove unneeded check in AsyncToSync.
current_executor is set unconditionally in the same block above.
1 parent a916061 commit 7181feb

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

asgiref/sync.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,17 @@ def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R:
233233
loop_future = loop_executor.submit(
234234
self._run_event_loop, loop, awaitable
235235
)
236-
if current_executor:
237-
# Run the CurrentThreadExecutor until the future is done
238-
current_executor.run_until_future(loop_future)
236+
# Run the CurrentThreadExecutor until the future is done.
237+
current_executor.run_until_future(loop_future)
239238
# Wait for future and/or allow for exception propagation
240239
loop_future.result()
241240
else:
242241
# Call it inside the existing loop
243242
self.main_event_loop.call_soon_threadsafe(
244243
self.main_event_loop.create_task, awaitable
245244
)
246-
if current_executor:
247-
# Run the CurrentThreadExecutor until the future is done
248-
current_executor.run_until_future(call_result)
245+
# Run the CurrentThreadExecutor until the future is done.
246+
current_executor.run_until_future(call_result)
249247
finally:
250248
# Clean up any executor we were running
251249
if loop is not None:

0 commit comments

Comments
 (0)