mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
asyncio doc: fix typo in an example
This commit is contained in:
parent
a9421fb3a3
commit
2cef300187
1 changed files with 6 additions and 4 deletions
|
|
@ -465,8 +465,8 @@ Use :class:`ProactorEventLoop` to support pipes on Windows.
|
||||||
Register write pipe in eventloop.
|
Register write pipe in eventloop.
|
||||||
|
|
||||||
*protocol_factory* should instantiate object with :class:`BaseProtocol`
|
*protocol_factory* should instantiate object with :class:`BaseProtocol`
|
||||||
interface. *pipe* is file-like object.
|
interface. *pipe* is :term:`file-like object <file object>`.
|
||||||
Return pair (transport, protocol), where *transport* supports
|
Return pair ``(transport, protocol)``, where *transport* supports
|
||||||
:class:`WriteTransport` interface.
|
:class:`WriteTransport` interface.
|
||||||
|
|
||||||
With :class:`SelectorEventLoop` event loop, the *pipe* is set to
|
With :class:`SelectorEventLoop` event loop, the *pipe* is set to
|
||||||
|
|
@ -734,12 +734,12 @@ Wait until a file descriptor received some data using the
|
||||||
def reader():
|
def reader():
|
||||||
data = rsock.recv(100)
|
data = rsock.recv(100)
|
||||||
print("Received:", data.decode())
|
print("Received:", data.decode())
|
||||||
# We are done: unregister the register
|
# We are done: unregister the file descriptor
|
||||||
loop.remove_reader(rsock)
|
loop.remove_reader(rsock)
|
||||||
# Stop the event loop
|
# Stop the event loop
|
||||||
loop.stop()
|
loop.stop()
|
||||||
|
|
||||||
# Wait for read event
|
# Register the file descriptor for read event
|
||||||
loop.add_reader(rsock, reader)
|
loop.add_reader(rsock, reader)
|
||||||
|
|
||||||
# Simulate the reception of data from the network
|
# Simulate the reception of data from the network
|
||||||
|
|
@ -790,3 +790,5 @@ the :meth:`BaseEventLoop.add_signal_handler` method::
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
finally:
|
finally:
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
This example only works on UNIX.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue