Skip to content

Commit

Permalink
Added stacklevel to warning in AsyncToSync.
Browse files Browse the repository at this point in the history
Outputs the line from the calling code when printing the warning, which makes it
easier to track down the problem without re-running with `-Werror`.
  • Loading branch information
carltongibson committed Oct 14, 2021
1 parent 4364f9b commit 6689c0a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion asgiref/sync.py
Expand Up @@ -122,7 +122,9 @@ def __init__(self, awaitable, force_new_loop=False):
if not callable(awaitable) or not _iscoroutinefunction_or_partial(awaitable):
# Python does not have very reliable detection of async functions
# (lots of false negatives) so this is just a warning.
warnings.warn("async_to_sync was passed a non-async-marked callable")
warnings.warn(
"async_to_sync was passed a non-async-marked callable", stacklevel=2
)
self.awaitable = awaitable
try:
self.__self__ = self.awaitable.__self__
Expand Down

0 comments on commit 6689c0a

Please sign in to comment.