From 63ea9e9cf98a601973ed00d4dd38860b76bce7ea Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Sat, 5 Oct 2024 10:37:10 +0200 Subject: [PATCH] Remove unneeded check in AsyncToSync. current_executor is set unconditionally in the same block above. --- asgiref/sync.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/asgiref/sync.py b/asgiref/sync.py index 87ee4064..377075d1 100644 --- a/asgiref/sync.py +++ b/asgiref/sync.py @@ -233,9 +233,8 @@ 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: @@ -243,9 +242,8 @@ def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R: 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: