async def create_site(self): return SockSite(self.runner, self.socket, shutdown_timeout=self.shutdown_timeout, ssl_context=await self.loop.run_in_executor(None, get_ssl_context, *self.__ssl_options))
async def create_site(self) -> SockSite: if self.runner is None: raise RuntimeError return SockSite( self.runner, self.socket, shutdown_timeout=self.shutdown_timeout, )
async def create_site(self) -> SockSite: if getattr(self, "runner", None) is None: raise RuntimeError("runner already created") return SockSite( self.runner, self.socket, shutdown_timeout=self.shutdown_timeout, )
async def octomachinery_app_tcp( ephemeral_port_tcp_sock, octomachinery_app_server_runner, ): """Run octomachinery web server and tear-down after testing.""" tcp_site = SockSite( octomachinery_app_server_runner, ephemeral_port_tcp_sock, ) await tcp_site.start() try: yield tcp_site finally: await tcp_site.stop()
async def start(self): self.runner = AppRunner( await self.create_application(), access_log_class=AccessLogger, access_log_format=AccessLogger.LOG_FORMAT, ) await self.runner.setup() self.site = SockSite( self.runner, self.socket, shutdown_timeout=self.shutdown_timeout ) await self.site.start()
def __init__( self, runner: AppRunner, context: ssl.SSLContext, snitun_server: str, snitun_port=None, ): """Initialize SniTunClient with aiohttp.""" self._connector = None self._client = ClientPeer(snitun_server, snitun_port) self._socket = socket.socket() self._server_name = "{}:{}".format(snitun_server, snitun_port) # Init interface self._socket.setblocking(False) self._socket.bind(("127.0.0.1", 0)) self._site = SockSite(runner, self._socket, ssl_context=context)
async def main(app, sock): runner = AppRunner(app) await runner.setup() site = SockSite(runner, sock, shutdown_timeout=3) await site.start()
async def create_site(self): return SockSite( self.runner, self.socket, shutdown_timeout=self.shutdown_timeout, )