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: