diff --git a/asgiref/current_thread_executor.py b/asgiref/current_thread_executor.py index a7898f85..0a9317ee 100644 --- a/asgiref/current_thread_executor.py +++ b/asgiref/current_thread_executor.py @@ -16,6 +16,7 @@ def __init__(self, future, fn, args, kwargs): self.kwargs = kwargs def run(self): + __traceback_hide__ = True # noqa: F841 if not self.future.set_running_or_notify_cancel(): return try: diff --git a/asgiref/sync.py b/asgiref/sync.py index faa6069b..8d100a09 100644 --- a/asgiref/sync.py +++ b/asgiref/sync.py @@ -167,6 +167,8 @@ def __init__(self, awaitable, force_new_loop=False): self.main_event_loop = None def __call__(self, *args, **kwargs): + __traceback_hide__ = True # noqa: F841 + # You can't call AsyncToSync from a thread with a running event loop try: event_loop = asyncio.get_running_loop() @@ -289,6 +291,9 @@ async def main_wrap( Wraps the awaitable with something that puts the result into the result/exception future. """ + + __traceback_hide__ = True # noqa: F841 + if context is not None: _restore_context(context[0]) @@ -388,6 +393,7 @@ def __init__( pass async def __call__(self, *args, **kwargs): + __traceback_hide__ = True # noqa: F841 loop = asyncio.get_running_loop() # Work out what thread to run the code in @@ -461,6 +467,9 @@ def thread_handler(self, loop, source_task, exc_info, func, *args, **kwargs): """ Wraps the sync application with exception handling. """ + + __traceback_hide__ = True # noqa: F841 + # Set the threadlocal for AsyncToSync self.threadlocal.main_event_loop = loop self.threadlocal.main_event_loop_pid = os.getpid()