Python asyncio.BaseTransport() Examples

The following are 11 code examples of asyncio.BaseTransport(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module asyncio , or try the search function .
Example #1
Source File: connection.py    From async-worker with MIT License 6 votes vote down vote up
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 
Example #2
Source File: discovery.py    From pyquarkchain with MIT License 5 votes vote down vote up
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) 
Example #3
Source File: statsd.py    From hypercorn with MIT License 5 votes vote down vote up
def __init__(self, config: Config) -> None:
        super().__init__(config)
        self.address = config.statsd_host.rsplit(":", 1)
        self.transport: Optional[asyncio.BaseTransport] = None 
Example #4
Source File: protocol.py    From grpclib with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #5
Source File: protocol.py    From bottom with MIT License 5 votes vote down vote up
def connection_made(self, transport: asyncio.BaseTransport) -> None:
        if MYPY:
            assert isinstance(transport, asyncio.WriteTransport)
        self.transport = transport 
Example #6
Source File: protocol.py    From aiosmtplib with MIT License 5 votes vote down vote up
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
            ) 
Example #7
Source File: web_protocol.py    From Galaxy_Plugin_Bethesda with MIT License 5 votes vote down vote up
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) 
Example #8
Source File: base_protocol.py    From Galaxy_Plugin_Bethesda with MIT License 5 votes vote down vote up
def connection_made(self, transport: asyncio.BaseTransport) -> None:
        tr = cast(asyncio.Transport, transport)
        tcp_nodelay(tr, True)
        self.transport = tr 
Example #9
Source File: tcp.py    From pyrdp with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #10
Source File: protocol.py    From pygls with Apache License 2.0 5 votes vote down vote up
def connection_made(self, transport: asyncio.BaseTransport):
        """Method from base class, called when connection is established"""
        self.transport = transport 
Example #11
Source File: asyncio_streams.py    From trinity with MIT License 5 votes vote down vote up
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