Skip to content

Commit f9a125c

Browse files
committed
Proper sniffio support requires Python 3.7
1 parent 2b9201a commit f9a125c

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

docs/source/usage.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ call async code from both contexts – they have different semantics, esp.
195195
concerning cancellation.
196196

197197
If you really need to do this, :meth:`sniffio.current_async_library`
198-
correctly reports "asyncio" when appropriate.
198+
correctly reports "asyncio" when appropriate. (This requires Python 3.7
199+
for :mod:`contextvars` support in :mod:`asyncio`.
199200

200201
.. _cross-calling:
201202

tests/interop/test_adapter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import trio
55
import sniffio
66
from tests import aiotest
7+
import sys
78

89

910
class SomeThing:
@@ -14,14 +15,16 @@ def __init__(self, loop):
1415

1516
@aio2trio
1617
async def dly_trio(self):
17-
assert sniffio.current_async_library() == "trio"
18+
if sys.version_info >= (3, 7):
19+
assert sniffio.current_async_library() == "trio"
1820
await trio.sleep(0.01)
1921
self.flag |= 2
2022
return 8
2123

2224
@trio2aio
2325
async def dly_asyncio(self):
24-
assert sniffio.current_async_library() == "asyncio"
26+
if sys.version_info >= (3, 7):
27+
assert sniffio.current_async_library() == "asyncio"
2528
await asyncio.sleep(0.01, loop=self.loop)
2629
self.flag |= 1
2730
return 4

tests/interop/test_calls.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sniffio
55
from tests import aiotest
66
from functools import partial
7+
import sys
78

89

910
class Seen:
@@ -24,7 +25,8 @@ def __init__(self, parent):
2425
async def __aenter__(self):
2526
assert self.parent.did_it == 0
2627
self.parent.did_it = 1
27-
assert sniffio.current_async_library() == "trio"
28+
if sys.version_info >= (3, 7):
29+
assert sniffio.current_async_library() == "trio"
2830
await trio.sleep(0.01)
2931
self.parent.did_it = 2
3032
return self
@@ -42,7 +44,8 @@ def __init__(self, parent, loop):
4244
async def __aenter__(self):
4345
assert self.parent.did_it == 0
4446
self.parent.did_it = 1
45-
assert sniffio.current_async_library() == "asyncio"
47+
if sys.version_info >= (3, 7):
48+
assert sniffio.current_async_library() == "asyncio"
4649
await asyncio.sleep(0.01, loop=self.loop)
4750
self.parent.did_it = 2
4851
return self

0 commit comments

Comments
 (0)