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

asyncioreactor almost certainly broken on Windows with Python 3.8 #9766

Closed
twisted-trac opened this issue Feb 18, 2020 · 7 comments
Closed

Comments

@twisted-trac
Copy link

cdunklau's avatar @cdunklau reported
Trac ID trac#9766
Type defect
Created 2020-02-18 00:46:12Z

AsyncioSelectorReactor uses get_event_loop by default, which is nice and convenient and good... except when the policy makes it return a non-SelectorEventLoop.

In bpo-34687, Python 3.8 made ProactorEventLoop the default for Windows , and that link also states:

ProactorEventLoop has the following limitations: The loop.add_reader() and loop.add_writer() methods are not supported.

So when you do try to use AsyncioSelectorReactor on py3.8+win, e.g. in the tests for pytest-twisted, you get a rather befuddling error:

<snip>
  File "c:\projects\pytest-twisted\.tox\py38-asyncioreactor\lib\site-packages\twisted\internet\asyncioreactor.py", line 320, in install
    reactor = AsyncioSelectorReactor(eventloop)
  File "c:\projects\pytest-twisted\.tox\py38-asyncioreactor\lib\site-packages\twisted\internet\asyncioreactor.py", line 69, in __init__
    super().__init__()
  File "c:\projects\pytest-twisted\.tox\py38-asyncioreactor\lib\site-packages\twisted\internet\base.py", line 571, in __init__
    self.installWaker()
  File "c:\projects\pytest-twisted\.tox\py38-asyncioreactor\lib\site-packages\twisted\internet\posixbase.py", line 286, in installWaker
    self.addReader(self.waker)
  File "c:\projects\pytest-twisted\.tox\py38-asyncioreactor\lib\site-packages\twisted\internet\asyncioreactor.py", line 151, in addReader
    self._asyncioEventloop.add_reader(fd, callWithLogger, reader,
  File "C:\Python38-x64\Lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

So, what to do? I hesitate to call the whole situation a Twisted defect, but I do think Twisted should not break in the face of something that should be detectable. I don't know really know the right way to detect this case... the first thought I had was "just typecheck against asyncio.BaseSelectorEventLoop"... which would work, but is maybe icky.

Searchable metadata
trac-id__9766 9766
type__defect defect
reporter__cdunklau cdunklau
priority__normal normal
milestone__Python_3_8_Support Python 3.8 Support
branch__ 
branch_author__ 
status__closed closed
resolution__fixed fixed
component__core core
keywords__None None
time__1581986772283411 1581986772283411
changetime__1600072597809031 1600072597809031
version__None None
owner__Craig_Rodrigues__rodrigc_____ Craig Rodrigues <rodrigc@...>

@twisted-trac
Copy link
Author

njsmith's avatar @njsmith commented

Tornado ran into the same issue and started a discussion upstream a few months ago: https://bugs.python.org/issue37373

@twisted-trac
Copy link
Author

rodrigc's avatar @rodrigc commented

#1338

@twisted-trac
Copy link
Author

altendky's avatar @altendky set owner to @rodrigc

Review:
#1338 (review)

Just a partial first pass as changes were added mid-review

@twisted-trac
Copy link
Author

rodrigc's avatar @rodrigc removed owner

@twisted-trac
Copy link
Author

altendky's avatar @altendky set owner to @rodrigc

Review: #1338 (comment)

@twisted-trac
Copy link
Author

rodrigc's avatar @rodrigc removed owner

Approved here: #1338 (review)

@twisted-trac
Copy link
Author

rodrigc's avatar @rodrigc set owner to @rodrigc
@rodrigc set status to closed

In changeset d8203ca

#!CommitTicketReference repository="" revision="d8203ca6e51705bd6246e063722fcd8596b7cbd3"
Merge pull request #1338 from twisted/9766-rodrigc-asyncio-selecteventorloop

Author: rodrigc
Reviewer: twm
Fixes: ticket:9766 ticket:9809

Fix AsyncioSelectorReactor on Windows Python 3.8+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant