Skip to content

Commit be6635e

Browse files
authored
Added __traceback_hide__ to skip frames in tracebacks (#383)
1 parent 0357158 commit be6635e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

asgiref/current_thread_executor.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def __init__(self, future, fn, args, kwargs):
1616
self.kwargs = kwargs
1717

1818
def run(self):
19+
__traceback_hide__ = True # noqa: F841
1920
if not self.future.set_running_or_notify_cancel():
2021
return
2122
try:

asgiref/sync.py

+9
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ def __init__(self, awaitable, force_new_loop=False):
167167
self.main_event_loop = None
168168

169169
def __call__(self, *args, **kwargs):
170+
__traceback_hide__ = True # noqa: F841
171+
170172
# You can't call AsyncToSync from a thread with a running event loop
171173
try:
172174
event_loop = asyncio.get_running_loop()
@@ -289,6 +291,9 @@ async def main_wrap(
289291
Wraps the awaitable with something that puts the result into the
290292
result/exception future.
291293
"""
294+
295+
__traceback_hide__ = True # noqa: F841
296+
292297
if context is not None:
293298
_restore_context(context[0])
294299

@@ -388,6 +393,7 @@ def __init__(
388393
pass
389394

390395
async def __call__(self, *args, **kwargs):
396+
__traceback_hide__ = True # noqa: F841
391397
loop = asyncio.get_running_loop()
392398

393399
# 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):
461467
"""
462468
Wraps the sync application with exception handling.
463469
"""
470+
471+
__traceback_hide__ = True # noqa: F841
472+
464473
# Set the threadlocal for AsyncToSync
465474
self.threadlocal.main_event_loop = loop
466475
self.threadlocal.main_event_loop_pid = os.getpid()

0 commit comments

Comments
 (0)