asyncio.open_connection
Prev: asyncio.new_event_loop | Up: asyncio | Next: asyncio.open_unix_connection
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.open_connection
Tags: #public #python3 #stdlib #asyncio
Import
import asyncio
from asyncio import open_connection
Signature & Overview
asyncio.open_connection(host=None, port=None, *, limit=65536, **kwds)
A wrapper for create_connection() returning a (reader, writer) pair.
Usage
import asyncio
# High-level TCP client returning (StreamReader, StreamWriter):
# reader, writer = await asyncio.open_connection("example.com", 443, ssl=True)
assert callable(asyncio.open_connection)
Gotchas
- Always close
writercleanly: Callwriter.close()followed byawait writer.wait_closed(), and callawait writer.drain()afterwriter.write(...)to respect backpressure.
REPL Inspect
from asyncio import open_connection
help(open_connection)
Linked from
Related notes
- tuts/python3/stdlib_module/asyncio/new_event_loop Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/open_unix_connection Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractEventLoop Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractServer Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/all_tasks Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/as_completed Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/Barrier shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseEventLoop shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseProtocol shared tags: #asyncio, #stdlib