Specify start_serving(). Add Post-History.
This commit is contained in:
parent
9bc98293d7
commit
aaa5fdfc7f
55
pep-3156.txt
55
pep-3156.txt
|
@ -7,7 +7,7 @@ Status: Draft
|
||||||
Type: Standards Track
|
Type: Standards Track
|
||||||
Content-Type: text/x-rst
|
Content-Type: text/x-rst
|
||||||
Created: 12-Dec-2012
|
Created: 12-Dec-2012
|
||||||
Post-History: TBD
|
Post-History: 21-Dec-2012
|
||||||
|
|
||||||
Abstract
|
Abstract
|
||||||
========
|
========
|
||||||
|
@ -257,7 +257,8 @@ Some methods in the standard conforming interface return Futures:
|
||||||
format as returned by ``socket.getaddrinfo()``. The default
|
format as returned by ``socket.getaddrinfo()``. The default
|
||||||
implementation calls ``socket.getaddrinfo()`` using
|
implementation calls ``socket.getaddrinfo()`` using
|
||||||
``run_in_executor()``, but other implementations may choose to
|
``run_in_executor()``, but other implementations may choose to
|
||||||
implement their own DNS lookup.
|
implement their own DNS lookup. The optional arguments *must* be
|
||||||
|
specified as keyword arguments.
|
||||||
|
|
||||||
- ``getnameinfo(sockaddr, flags=0)``. Similar to
|
- ``getnameinfo(sockaddr, flags=0)``. Similar to
|
||||||
``socket.getnameinfo()`` but returns a Future. The Future's result
|
``socket.getnameinfo()`` but returns a Future. The Future's result
|
||||||
|
@ -267,7 +268,8 @@ Some methods in the standard conforming interface return Futures:
|
||||||
- ``create_transport(protocol_factory, host, port, **kwargs)``.
|
- ``create_transport(protocol_factory, host, port, **kwargs)``.
|
||||||
Creates a transport and a protocol and ties them together. Returns
|
Creates a transport and a protocol and ties them together. Returns
|
||||||
a Future whose result on success is a (transport, protocol) pair.
|
a Future whose result on success is a (transport, protocol) pair.
|
||||||
Note that when the Future completes, the protocol's
|
The protocol is created by calling ``protocol_factory()`` without
|
||||||
|
arguments. Note that when the Future completes, the protocol's
|
||||||
``connection_made()`` method has not yet been called; that will
|
``connection_made()`` method has not yet been called; that will
|
||||||
happen when the connection handshake is complete. When it is
|
happen when the connection handshake is complete. When it is
|
||||||
impossible to connect to the given host and port, the Future will
|
impossible to connect to the given host and port, the Future will
|
||||||
|
@ -286,36 +288,31 @@ Some methods in the standard conforming interface return Futures:
|
||||||
|
|
||||||
TBD: Should this be called create_connection()?
|
TBD: Should this be called create_connection()?
|
||||||
|
|
||||||
- ``start_serving(...)``. Enters a loop that accepts connections.
|
- ``start_serving(protocol_factory, host, port, **kwds)``. Enters a
|
||||||
TBD: Signature. There are two possibilities:
|
loop that accepts connections. Returns a Future that completes once
|
||||||
|
the loop is set up to serve; its return value is None. Each time a
|
||||||
|
connection is accepted, ``protocol_factory`` is called without
|
||||||
|
arguments to create a protocol, a transport is created to represent
|
||||||
|
the network side of the connection, and the two are tied together by
|
||||||
|
calling ``protocol.connection_made(transport)``.
|
||||||
|
|
||||||
1. You pass it a non-blocking socket that you have already prepared
|
Optional keyword arguments:
|
||||||
with ``bind()`` and ``listen()`` (these system calls do not block
|
|
||||||
AFAIK), a protocol factory (I hesitate to use this word :-), and
|
|
||||||
optional flags that control the transport creation (e.g. ssl).
|
|
||||||
|
|
||||||
2. Instead of a socket, you pass it a host and port, and some more
|
- ``family``, ``type``, ``proto``, ``flags``: Address familty,
|
||||||
optional flags (e.g. to control IPv4 vs IPv6, or to set the
|
socket type, protcol, and miscellaneous flags to be passed through
|
||||||
backlog value to be passed to ``listen()``).
|
to ``getaddrinfo()``. These all default to ``0`` except ``type``
|
||||||
|
which defaults to ``socket.SOCK_STREAM``.
|
||||||
|
|
||||||
In either case, once it has a socket, it will wrap it in a
|
TBD: Support SSL? I don't even know how to do that synchronously,
|
||||||
transport, and then enter a loop accepting connections (the best way
|
and I suppose it needs a certificate.
|
||||||
to implement such a loop depends on the platform). Each time a
|
|
||||||
connection is accepted, a transport and protocol are created for it.
|
|
||||||
|
|
||||||
This should return an object that can be used to control the serving
|
TBD: Maybe make the Future's result an object that can be used to
|
||||||
loop, e.g. to stop serving, abort all active connections, and (if
|
control the serving loop, e.g. to stop serving, abort all active
|
||||||
supported) adjust the backlog or other parameters. It may also have
|
connections, and (if supported) adjust the backlog or other
|
||||||
an API to inquire about active connections. If version (2) is
|
parameters? It could also have an API to inquire about active
|
||||||
selected, it should probably return a Future whose result on success
|
connections. Alternatively, return a Future (subclass?) that only
|
||||||
will be that control object, and which becomes done once the accept
|
completes if the loop stops serving due to an error, or if it cannot
|
||||||
loop is started.
|
be started? Cancelling it might stop the loop.
|
||||||
|
|
||||||
TBD: It may be best to use version (2), since on some platforms the
|
|
||||||
best way to start a server may not involve sockets (but will still
|
|
||||||
involve transports and protocols).
|
|
||||||
|
|
||||||
TBD: Be more specific.
|
|
||||||
|
|
||||||
TBD: Some platforms may not be interested in implementing all of
|
TBD: Some platforms may not be interested in implementing all of
|
||||||
these, e.g. start_serving() may be of no interest to mobile apps.
|
these, e.g. start_serving() may be of no interest to mobile apps.
|
||||||
|
|
Loading…
Reference in New Issue