On this page
asyncio.BaseProtocol
Prev: asyncio.BaseEventLoop | Up: asyncio | Next: asyncio.BaseTransport
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.BaseProtocol
Tags: #public #python3 #stdlib #asyncio
Import
import asyncio
from asyncio import BaseProtocol
Signature & Overview
asyncio.BaseProtocol()
Common base class for protocol interfaces.
Methods & Attributes
BaseProtocol.connection_lost(self, exc)— Called when the connection is lost or closed.BaseProtocol.connection_made(self, transport)— Called when a connection is made.BaseProtocol.pause_writing(self)— Called when the transport's buffer goes over the high-water mark.BaseProtocol.resume_writing(self)— Called when the transport's buffer drains below the low-water mark.
Usage
import asyncio
class EchoProtocol(asyncio.BaseProtocol):
def connection_made(self, transport): self.transport = transport
assert issubclass(EchoProtocol, asyncio.BaseProtocol)
Gotchas
- Low-level callback API: For most TCP apps, high-level
asyncio.open_connection()/asyncio.start_server()streams are simpler than customProtocolclasses.
REPL Inspect
from asyncio import BaseProtocol
help(BaseProtocol)
Linked from
Related notes
- tuts/python3/stdlib_module/asyncio/BaseEventLoop Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseTransport 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/BoundedSemaphore shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BrokenBarrierError shared tags: #asyncio, #stdlib