Skip to content

Commit

Permalink
Refactored socket/stream code
Browse files Browse the repository at this point in the history
- Used transports and protocols on asyncio for compatibility with ProactorEventLoop
- Used trustme to provide dummy certificates
- Separated TLS from TCP streams
- Separated buffering functionality from the SocketStream class into BufferedByteReceiveStream
- Added the "family" property to socket streams
- Added text streams

Fixes agronholm#77. Fixes agronholm#7.
  • Loading branch information
agronholm authored and mjwestcott committed Aug 5, 2020
1 parent 46ff7fa commit 2c43116
Show file tree
Hide file tree
Showing 37 changed files with 3,231 additions and 2,144 deletions.
103 changes: 71 additions & 32 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Timeouts and cancellation
.. autofunction:: anyio.current_effective_deadline
.. autofunction:: anyio.current_time

.. autoclass:: anyio.abc.CancelScope
.. autoclass:: anyio.abc.tasks.CancelScope
:members:

Task groups
-----------

.. autofunction:: anyio.create_task_group

.. autoclass:: anyio.abc.TaskGroup
.. autoclass:: anyio.abc.tasks.TaskGroup
:members:

Threads
Expand All @@ -46,41 +46,88 @@ Async file I/O

.. autoclass:: anyio.fileio.AsyncFile

Streams
-------

.. autoclass:: anyio.abc.UnreliableObjectReceiveStream
.. autoclass:: anyio.abc.UnreliableObjectSendStream
.. autoclass:: anyio.abc.UnreliableObjectStream
.. autoclass:: anyio.abc.ObjectReceiveStream
.. autoclass:: anyio.abc.ObjectSendStream
.. autoclass:: anyio.abc.ObjectStream
.. autoclass:: anyio.abc.ByteReceiveStream
.. autoclass:: anyio.abc.ByteSendStream
.. autoclass:: anyio.abc.ByteStream
Streams and stream wrappers
---------------------------

.. autoclass:: anyio.abc.streams.UnreliableObjectReceiveStream
.. autoclass:: anyio.abc.streams.UnreliableObjectSendStream
.. autoclass:: anyio.abc.streams.UnreliableObjectStream
.. autoclass:: anyio.abc.streams.ObjectReceiveStream
.. autoclass:: anyio.abc.streams.ObjectSendStream
.. autoclass:: anyio.abc.streams.ObjectStream
.. autoclass:: anyio.abc.streams.ByteReceiveStream
.. autoclass:: anyio.abc.streams.ByteSendStream
.. autoclass:: anyio.abc.streams.ByteStream
.. autoclass:: anyio.abc.streams.Listener
.. autodata:: anyio.abc.streams.AnyUnreliableByteReceiveStream
.. autodata:: anyio.abc.streams.AnyUnreliableByteSendStream
.. autodata:: anyio.abc.streams.AnyUnreliableByteStream
.. autodata:: anyio.abc.streams.AnyByteReceiveStream
.. autodata:: anyio.abc.streams.AnyByteSendStream
.. autodata:: anyio.abc.streams.AnyByteStream

.. autofunction:: anyio.create_memory_object_stream

.. autofunction:: anyio.serve_listeners

.. autoclass:: anyio.streams.buffered.BufferedByteReceiveStream
:members:

.. autoclass:: anyio.streams.memory.MemoryObjectReceiveStream
:members:

.. autoclass:: anyio.streams.memory.MemoryObjectSendStream
:members:

.. autoclass:: anyio.streams.stapled.StapledByteStream
:members:

.. autoclass:: anyio.streams.stapled.StapledObjectStream
:members:

.. autoclass:: anyio.streams.text.TextReceiveStream
:members:

.. autoclass:: anyio.streams.text.TextSendStream
:members:

.. autoclass:: anyio.streams.text.TextStream
:members:

.. autoclass:: anyio.streams.tls.TLSStream
:members:

.. autoclass:: anyio.streams.tls.TLSListener
:members:

Sockets and networking
----------------------

.. autofunction:: anyio.connect_tcp
.. autofunction:: anyio.connect_tcp_with_tls
.. autofunction:: anyio.connect_unix
.. autofunction:: anyio.create_tcp_server
.. autofunction:: anyio.create_unix_server
.. autofunction:: anyio.create_tcp_listeners
.. autofunction:: anyio.create_unix_listener
.. autofunction:: anyio.create_udp_socket
.. autofunction:: anyio.create_connected_udp_socket
.. autofunction:: anyio.getaddrinfo
.. autofunction:: anyio.getnameinfo
.. autofunction:: anyio.wait_socket_readable
.. autofunction:: anyio.wait_socket_writable
.. autofunction:: anyio.notify_socket_close

.. autoclass:: anyio.abc.SocketStream
.. autoclass:: anyio.abc.sockets.SocketStream
:members:
:show-inheritance:

.. autoclass:: anyio.abc.SocketStreamServer
.. autoclass:: anyio.abc.sockets.SocketListener
:members:
:show-inheritance:

.. autoclass:: anyio.abc.sockets.UDPSocket
:members:

.. autoclass:: anyio.abc.UDPSocket
.. autoclass:: anyio.abc.sockets.ConnectedUDPSocket
:members:

Synchronization
Expand All @@ -91,27 +138,20 @@ Synchronization
.. autofunction:: anyio.create_event
.. autofunction:: anyio.create_condition
.. autofunction:: anyio.create_capacity_limiter
.. autofunction:: anyio.create_memory_object_stream

.. autoclass:: anyio.abc.Semaphore
:members:

.. autoclass:: anyio.abc.Lock
:members:

.. autoclass:: anyio.abc.Event
.. autoclass:: anyio.abc.synchronization.Semaphore
:members:

.. autoclass:: anyio.abc.Condition
.. autoclass:: anyio.abc.synchronization.Lock
:members:

.. autoclass:: anyio.abc.CapacityLimiter
.. autoclass:: anyio.abc.synchronization.Event
:members:

.. autoclass:: anyio.synchronization.MemoryObjectReceiveStream
.. autoclass:: anyio.abc.synchronization.Condition
:members:

.. autoclass:: anyio.synchronization.MemoryObjectSendStream
.. autoclass:: anyio.abc.synchronization.CapacityLimiter
:members:

Operating system signals
Expand All @@ -137,5 +177,4 @@ Exceptions
.. autoexception:: anyio.exceptions.EndOfStream
.. autoexception:: anyio.exceptions.ExceptionGroup
.. autoexception:: anyio.exceptions.IncompleteRead
.. autoexception:: anyio.exceptions.TLSRequired
.. autoexception:: anyio.exceptions.WouldBlock
4 changes: 2 additions & 2 deletions docs/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ of your choice. There are a few rules to keep in mind however:
use a library written for trio together with a library written for asyncio.
* Tasks spawned by these "native" libraries on backends other than trio_ are not subject to the
cancellation rules enforced by AnyIO
* Threads spawned outside of AnyIO cannot use :func:`~run_async_from_thread` to call asynchronous
code
* Threads spawned outside of AnyIO cannot use :func:`~anyio.run_async_from_thread` to call
asynchronous code

.. _virtualenv: https://docs.python-guide.org/dev/virtualenvs/
.. _trio: https://github.com/python-trio/trio
Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ The manual
tasks
cancellation
synchronization
streams
networking
threads
fileio
networking
signals
testing
api
Expand Down
Loading

0 comments on commit 2c43116

Please sign in to comment.