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

If <3.7 and no get_running_loop, return false. #107

Merged
merged 1 commit into from
Mar 24, 2020
Merged
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
15 changes: 7 additions & 8 deletions beeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@

try:
import asyncio
# The async functionality uses the contextvars module, added in
# Python 3.7
import contextvars
assert contextvars
try:
asyncio.get_running_loop() # pylint: disable=no-member
except RuntimeError:
pass

from beeline.aiotrace import AsyncioTracer, traced_impl, untraced
assert untraced

def in_async_code():
"""Return wether we are running inside an asynchronous task.
"""Return whether we are running inside an asynchronous task.

We use this information to determine which tracer
implementation to use.
Expand All @@ -42,9 +42,8 @@ def in_async_code():
except RuntimeError:
return False

except ImportError:
# Use these non-async versions if we don't have asyncio or
# contextvars.
except (ImportError, AttributeError):
# Use these non-async versions if we don't have asyncio.
from beeline.trace import traced_impl

def in_async_code():
Expand Down