Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3f8e30

Browse files
committed
asyncio.docs: Improve documentation of Streams. Issue #20696.
1 parent 389b036 commit d3f8e30

1 file changed

Lines changed: 43 additions & 29 deletions

File tree

Doc/library/asyncio-stream.rst

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Stream functions
3434

3535
.. function:: start_server(client_connected_cb, host=None, port=None, \*, loop=None, limit=None, **kwds)
3636

37-
Start a socket server, call back for each client connected.
37+
Start a socket server, with a callback for each client connected.
3838

3939
The first parameter, *client_connected_cb*, takes two parameters:
4040
*client_reader*, *client_writer*. *client_reader* is a
@@ -58,6 +58,29 @@ Stream functions
5858

5959
This function returns a :ref:`coroutine object <coroutine>`.
6060

61+
.. function:: open_unix_connection(path=None, \*, loop=None, limit=None, **kwds)
62+
63+
A wrapper for :meth:`~BaseEventLoop.create_unix_connection()` returning
64+
a (reader, writer) pair.
65+
66+
See :func:`open_connection` for information about return value and other
67+
details.
68+
69+
This function returns a :ref:`coroutine object <coroutine>`.
70+
71+
Availability: UNIX.
72+
73+
.. function:: start_unix_server(client_connected_cb, path=None, \*, loop=None, limit=None, **kwds)
74+
75+
Start a UNIX Domain Socket server, with a callback for each client connected.
76+
77+
See :func:`start_server` for information about return value and other
78+
details.
79+
80+
This function returns a :ref:`coroutine object <coroutine>`.
81+
82+
Availability: UNIX.
83+
6184

6285
StreamReader
6386
============
@@ -70,11 +93,12 @@ StreamReader
7093

7194
.. method:: feed_eof()
7295

73-
XXX
96+
Acknowledge the EOF.
7497

7598
.. method:: feed_data(data)
7699

77-
XXX
100+
Feed *data* bytes in the internal buffer. Any operations waiting
101+
for the data will be resumed.
78102

79103
.. method:: set_exception(exc)
80104

@@ -86,13 +110,23 @@ StreamReader
86110

87111
.. method:: read(n=-1)
88112

89-
XXX
113+
Read up to *n* bytes. If *n* is not provided, or set to ``-1``,
114+
read until EOF and return all read bytes.
115+
116+
If the EOF was received and the internal buffer is empty,
117+
return an empty ``bytes`` object.
90118

91119
This method returns a :ref:`coroutine object <coroutine>`.
92120

93121
.. method:: readline()
94122

95-
XXX
123+
Read one line, where "line" is a sequence of bytes ending with ``\n``.
124+
125+
If EOF is received, and ``\n`` was not found, the method will
126+
return the partial read bytes.
127+
128+
If the EOF was received and the internal buffer is empty,
129+
return an empty ``bytes`` object.
96130

97131
This method returns a :ref:`coroutine object <coroutine>`.
98132

@@ -105,6 +139,10 @@ StreamReader
105139

106140
This method returns a :ref:`coroutine object <coroutine>`.
107141

142+
.. method:: at_eof()
143+
144+
Return ``True`` if the buffer is empty and :meth:`feed_eof` was called.
145+
108146

109147
StreamWriter
110148
============
@@ -186,30 +224,6 @@ StreamReaderProtocol
186224
potential uses, and to prevent the user of the :class:`StreamReader` to
187225
accidentally call inappropriate methods of the protocol.)
188226

189-
.. method:: connection_made(transport)
190-
191-
XXX
192-
193-
.. method:: connection_lost(exc)
194-
195-
XXX
196-
197-
.. method:: data_received(data)
198-
199-
XXX
200-
201-
.. method:: eof_received()
202-
203-
XXX
204-
205-
.. method:: pause_writing()
206-
207-
XXX
208-
209-
.. method:: resume_writing()
210-
211-
XXX
212-
213227

214228
IncompleteReadError
215229
===================

0 commit comments

Comments
 (0)