本文整理汇总了Python中asyncio.BaseTransport方法的典型用法代码示例。如果您正苦于以下问题:Python asyncio.BaseTransport方法的具体用法?Python asyncio.BaseTransport怎么用?Python asyncio.BaseTransport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asyncio
的用法示例。
在下文中一共展示了asyncio.BaseTransport方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def __init__(
self,
host: str,
username: str,
password: str,
heartbeat: int = 60,
virtual_host: str = "/",
loop: asyncio.AbstractEventLoop = None,
on_error: OnErrorCallback = None,
) -> None:
self.host = host
self.username = username
self.password = password
self.virtual_host = virtual_host
self.heartbeat = heartbeat
self.loop = loop
self._on_error = on_error
self._connection_lock = asyncio.Lock()
self.channel: Channel = None
self._transport: Optional[asyncio.BaseTransport] = None
self._protocol: AmqpProtocol = None
示例2: connection_made
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def connection_made(self, transport: asyncio.BaseTransport) -> None:
# we need to cast here because the signature in the base class dicates BaseTransport
# and arguments can only be redefined contravariantly
self.transport = cast(asyncio.DatagramTransport, transport)
示例3: __init__
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def __init__(self, config: Config) -> None:
super().__init__(config)
self.address = config.statsd_host.rsplit(":", 1)
self.transport: Optional[asyncio.BaseTransport] = None
示例4: connection_made
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def connection_made(self, transport: BaseTransport) -> None:
sock = transport.get_extra_info('socket')
if sock is not None:
_set_nodelay(sock)
h2_conn = H2Connection(config=self.h2_config)
h2_conn.initiate_connection()
initial = h2_conn.local_settings.initial_window_size
conn_delta = self.config.http2_connection_window_size - initial
stream_delta = self.config.http2_stream_window_size - initial
if conn_delta:
h2_conn.increment_flow_control_window(conn_delta)
if stream_delta:
h2_conn.update_settings({
SettingCodes.INITIAL_WINDOW_SIZE:
self.config.http2_stream_window_size,
})
self.connection = Connection(
h2_conn,
cast(Transport, transport),
config=self.config,
)
self.connection.flush()
self.connection.initialize()
self.processor = EventsProcessor(self.handler, self.connection)
示例5: connection_made
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def connection_made(self, transport: asyncio.BaseTransport) -> None:
if MYPY:
assert isinstance(transport, asyncio.WriteTransport)
self.transport = transport
示例6: connection_made
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def connection_made(self, transport: asyncio.BaseTransport) -> None:
self.transport = cast(asyncio.Transport, transport)
self._over_ssl = transport.get_extra_info("sslcontext") is not None
self._response_waiter = self._loop.create_future()
self._command_lock = asyncio.Lock()
if self._connection_lost_callback is not None:
self._connection_lost_waiter = self._loop.create_future()
self._connection_lost_waiter.add_done_callback(
self._connection_lost_callback
)
示例7: connection_made
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def connection_made(self, transport: asyncio.BaseTransport) -> None:
super().connection_made(transport)
real_transport = cast(asyncio.Transport, transport)
if self._tcp_keepalive:
tcp_keepalive(real_transport)
self._task_handler = self._loop.create_task(self.start())
assert self._manager is not None
self._manager.connection_made(self, real_transport)
示例8: connection_made
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def connection_made(self, transport: asyncio.BaseTransport) -> None:
tr = cast(asyncio.Transport, transport)
tcp_nodelay(tr, True)
self.transport = tr
示例9: connection_made
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def connection_made(self, transport: asyncio.BaseTransport):
"""
When the TCP handshake is completed, notify the observer.
"""
self.transport = transport
self.connectedEvent.set()
self.observer.onConnection()
示例10: connection_made
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def connection_made(self, transport: asyncio.BaseTransport):
"""Method from base class, called when connection is established"""
self.transport = transport
示例11: __init__
# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import BaseTransport [as 别名]
def __init__(self,
reader: asyncio.StreamReader,
extra: Dict[str, Any] = None) -> None:
self._is_closing = False
self._reader = reader
super().__init__(extra)
#
# BaseTransport methods
#
# methods we don't overwrite because they already raise NotImplementedError
# and we don't need them
# - set_protocol
# - get_protocol