@@ -71,8 +71,8 @@ It provides multiple facilities, amongst which:
7171
7272* Delegating costly function calls to a pool of threads
7373
74- Getting an event loop
75- ^^^^^^^^^^^^^^^^^^^^^
74+ Event loop functions
75+ ^^^^^^^^^^^^^^^^^^^^
7676
7777The easiest way to get an event loop is to call the :func: `get_event_loop `
7878function.
@@ -84,6 +84,26 @@ function.
8484 event loop has been set for the current context and the current policy does
8585 not specify to create one. It should never return ``None ``.
8686
87+ .. function :: set_event_loop(loop)
88+
89+ XXX
90+
91+ .. function :: new_event_loop()
92+
93+ XXX
94+
95+
96+ Event loop policy
97+ ^^^^^^^^^^^^^^^^^
98+
99+ .. function :: get_event_loop_policy()
100+
101+ XXX
102+
103+ .. function :: set_event_loop_policy(policy)
104+
105+ XXX
106+
87107
88108Run an event loop
89109^^^^^^^^^^^^^^^^^
@@ -114,11 +134,14 @@ Run an event loop
114134
115135.. method :: BaseEventLoop.close()
116136
117- Close the event loop.
137+ Close the event loop. The loop should not be running.
118138
119139 This clears the queues and shuts down the executor, but does not wait for
120140 the executor to finish.
121141
142+ This is idempotent and irreversible. No other methods should be called after
143+ this one.
144+
122145
123146Calls
124147^^^^^
@@ -199,26 +222,41 @@ Creating listening connections
199222
200223.. method :: BaseEventLoop.create_server(protocol_factory, host=None, port=None, \*, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None)
201224
202- XXX
225+ A :ref: `coroutine <coroutine >` which creates a TCP server bound to host and
226+ port.
227+
228+ The return value is a Server object which can be used to stop
229+ the service.
230+
231+ If *host * is an empty string or None all interfaces are assumed
232+ and a list of multiple sockets will be returned (most likely
233+ one for IPv4 and another one for IPv6).
203234
204- * *protocol_factory *
205- * *host *, *port *
206- * *family *
207- * *flags *
208- * *sock *
209- * *backlog * : the maximum number of queued connections and should be at
210- least ``0 ``; the maximum value is system-dependent (usually ``5 ``),
211- the minimum value is forced to ``0 ``.
212- * *ssl *: ``True `` or :class: `ssl.SSLContext `
213- * *reuse_address *: if ``True ``, set :data: `socket.SO_REUSEADDR ` option
214- on the listening socket. Default value: ``True `` on POSIX systems,
215- ``False `` on Windows.
235+ *family * can be set to either :data: `~socket.AF_INET ` or
236+ :data: `~socket.AF_INET6 ` to force the socket to use IPv4 or IPv6. If not set
237+ it will be determined from host (defaults to :data: `~socket.AF_UNSPEC `).
238+
239+ *flags * is a bitmask for :meth: `getaddrinfo `.
240+
241+ *sock * can optionally be specified in order to use a preexisting
242+ socket object.
243+
244+ *backlog * is the maximum number of queued connections passed to
245+ :meth: `~socket.socket.listen ` (defaults to 100).
246+
247+ ssl can be set to an :class: `~ssl.SSLContext ` to enable SSL over the
248+ accepted connections.
249+
250+ *reuse_address * tells the kernel to reuse a local socket in
251+ TIME_WAIT state, without waiting for its natural timeout to
252+ expire. If not specified will automatically be set to True on
253+ UNIX.
216254
217255 This method returns a :ref: `coroutine <coroutine >`.
218256
219257.. method :: BaseEventLoop.create_datagram_endpoint(protocol_factory, local_addr=None, remote_addr=None, \*, family=0, proto=0, flags=0)
220258
221- XXX
259+ Create datagram connection.
222260
223261 This method returns a :ref: `coroutine <coroutine >`.
224262
@@ -291,13 +329,23 @@ Creating connections
291329
292330.. method :: BaseEventLoop.connect_read_pipe(protocol_factory, pipe)
293331
294- XXX
332+ Register read pipe in eventloop.
333+
334+ *protocol_factory * should instantiate object with :class: `Protocol `
335+ interface. pipe is file-like object already switched to nonblocking.
336+ Return pair (transport, protocol), where transport support
337+ :class: `ReadTransport ` interface.
295338
296339 This method returns a :ref: `coroutine <coroutine >`.
297340
298341.. method :: BaseEventLoop.connect_write_pipe(protocol_factory, pipe)
299342
300- XXX
343+ Register write pipe in eventloop.
344+
345+ *protocol_factory * should instantiate object with :class: `BaseProtocol `
346+ interface. Pipe is file-like object already switched to nonblocking.
347+ Return pair (transport, protocol), where transport support
348+ :class: `WriteTransport ` interface.
301349
302350 This method returns a :ref: `coroutine <coroutine >`.
303351
@@ -1047,6 +1095,22 @@ it running: call ``yield from coroutine`` from another coroutine
10471095Coroutines (and tasks) can only run when the event loop is running.
10481096
10491097
1098+ Server
1099+ ------
1100+
1101+ .. class :: AbstractServer
1102+
1103+ Abstract server returned by create_service().
1104+
1105+ .. method :: close()
1106+
1107+ Stop serving. This leaves existing connections open.
1108+
1109+ .. method :: wait_closed()
1110+
1111+ Coroutine to wait until service is closed.
1112+
1113+
10501114.. _sync :
10511115
10521116Synchronization primitives
0 commit comments