Skip to content

Commit 0bdf552

Browse files
committed
Add notes about py3.8/asyncio/proactor to readme
1 parent 5e84a28 commit 0bdf552

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,47 @@ which uses the twisted framework. test functions can return Deferred
1818
objects and pytest will wait for their completion with this plugin.
1919

2020

21+
NOTICE: Python 3.8 with asyncio support
22+
=======================================
23+
24+
In Python 3.8, asyncio changed the default loop implementation to use
25+
their proactor. The proactor does not implement some methods used by
26+
Twisted's asyncio support. The result is a ``NotImplementedError``
27+
exception such as below.
28+
29+
.. code-block:: pytb
30+
31+
<snip>
32+
File "c:\projects\pytest-twisted\.tox\py38-asyncioreactor\lib\site-packages\twisted\internet\asyncioreactor.py", line 320, in install
33+
reactor = AsyncioSelectorReactor(eventloop)
34+
File "c:\projects\pytest-twisted\.tox\py38-asyncioreactor\lib\site-packages\twisted\internet\asyncioreactor.py", line 69, in __init__
35+
super().__init__()
36+
File "c:\projects\pytest-twisted\.tox\py38-asyncioreactor\lib\site-packages\twisted\internet\base.py", line 571, in __init__
37+
self.installWaker()
38+
File "c:\projects\pytest-twisted\.tox\py38-asyncioreactor\lib\site-packages\twisted\internet\posixbase.py", line 286, in installWaker
39+
self.addReader(self.waker)
40+
File "c:\projects\pytest-twisted\.tox\py38-asyncioreactor\lib\site-packages\twisted\internet\asyncioreactor.py", line 151, in addReader
41+
self._asyncioEventloop.add_reader(fd, callWithLogger, reader,
42+
File "C:\Python38-x64\Lib\asyncio\events.py", line 501, in add_reader
43+
raise NotImplementedError
44+
NotImplementedError
45+
46+
The previous default, the selector loop, still works but you have to
47+
explicitly set it. ``pytest_twisted.use_asyncio_selector_if_required()``
48+
is provided to help in choosing the selector loop. It must be called
49+
early so the following `conftest.py` is suggested.
50+
51+
.. code-block:: python3
52+
53+
import pytest
54+
import pytest_twisted
55+
56+
57+
@pytest.hookimpl(tryfirst=True)
58+
def pytest_configure(config):
59+
pytest_twisted.use_asyncio_selector_if_required(config=config)
60+
61+
2162
Python 2 support plans
2263
======================
2364

0 commit comments

Comments
 (0)