Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use __traceback_hide__ to skip frames in tracebacks #383

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions asgiref/current_thread_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions asgiref/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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])

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down