Skip to content

Commit

Permalink
Mitigated the effects of ProactorEventLoop as default on Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Oct 4, 2019
1 parent c993201 commit 43f87d0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions anyio/_backends/_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 76,10 @@ async def wrapper():
else:
policy = uvloop.EventLoopPolicy()

# Must be explicitly set on Python 3.8 for now or wait_socket_(readable|writable) won't work
if policy is None and sys.platform == 'win32':
policy = asyncio.WindowsSelectorEventLoopPolicy() # type: ignore

if policy is not None:
asyncio.set_event_loop_policy(policy)

Expand Down
6 changes: 6 additions & 0 deletions docs/networking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 13,12 @@ Currently AnyIO offers the following networking functionality:

More exotic forms of networking such as raw sockets and SCTP are currently not supported.

.. warning:: With the combination of Windows, Python 3.8 and asyncio, AnyIO currently requires the
use of :class:`asyncio.SelectorEventLoop`. The appropriate event loop policy is automatically
set when calling :func:`anyio.run()`, but applications using AnyIO network functionality
directly without explicitly switching to the selector event loop policy will fail. This
limitation is expected to be lifted in the 2.0 release.

Working with TCP sockets
------------------------

Expand Down
2 changes: 2 additions & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 10,8 @@ This library adheres to `Semantic Versioning 2.0 <http://semver.org/>`_.
- Fixed ``KeyError`` on asyncio and curio where entering and exiting a cancel scope happens in
different tasks
- Fixed deprecation warnings on Python 3.8 about the ``loop`` argument of ``asyncio.Event()``
- Forced the use ``WindowsSelectorEventLoopPolicy`` in ``asyncio.run`` when on Windows and asyncio
to keep network functionality working
- Dropped support for trio v0.11

**1.1.0**
Expand Down

0 comments on commit 43f87d0

Please sign in to comment.