Skip to content

Commit

Permalink
Merge pull request #21 from graingert/patch-1
Browse files Browse the repository at this point in the history
swap asyncio/curio checks
  • Loading branch information
njsmith authored Mar 4, 2021
2 parents 4a33d64 + 920a29a commit e8de439
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sniffio/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ async def generic_sleep(seconds):
if value is not None:
return value

# Sniff for curio (for now)
if 'curio' in sys.modules:
from curio.meta import curio_running
if curio_running():
return 'curio'

# Need to sniff for asyncio
if "asyncio" in sys.modules:
import asyncio
Expand All @@ -78,6 +72,13 @@ async def generic_sleep(seconds):
return "asyncio"
except RuntimeError:
pass

# Sniff for curio (for now)
if 'curio' in sys.modules:
from curio.meta import curio_running
if curio_running():
return 'curio'

raise AsyncLibraryNotFoundError(
"unknown async library, or not in async context"
)

0 comments on commit e8de439

Please sign in to comment.