A wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and
(host=None, port=None, *,
limit=_DEFAULT_LIMIT, **kwds)
| 24 | |
| 25 | |
| 26 | async def open_connection(host=None, port=None, *, |
| 27 | limit=_DEFAULT_LIMIT, **kwds): |
| 28 | """A wrapper for create_connection() returning a (reader, writer) pair. |
| 29 | |
| 30 | The reader returned is a StreamReader instance; the writer is a |
| 31 | StreamWriter instance. |
| 32 | |
| 33 | The arguments are all the usual arguments to create_connection() |
| 34 | except protocol_factory; most common are positional host and port, |
| 35 | with various optional keyword arguments following. |
| 36 | |
| 37 | Additional optional keyword arguments are loop (to set the event loop |
| 38 | instance to use) and limit (to set the buffer limit passed to the |
| 39 | StreamReader). |
| 40 | |
| 41 | (If you want to customize the StreamReader and/or |
| 42 | StreamReaderProtocol classes, just copy the code -- there's |
| 43 | really nothing special here except some convenience.) |
| 44 | """ |
| 45 | loop = events.get_running_loop() |
| 46 | reader = StreamReader(limit=limit, loop=loop) |
| 47 | protocol = StreamReaderProtocol(reader, loop=loop) |
| 48 | transport, _ = await loop.create_connection( |
| 49 | lambda: protocol, host, port, **kwds) |
| 50 | writer = StreamWriter(transport, protocol, reader, loop) |
| 51 | return reader, writer |
| 52 | |
| 53 | |
| 54 | async def start_server(client_connected_cb, host=None, port=None, *, |
nothing calls this directly
no test coverage detected
searching dependent graphs…