How to use the aiomisc.service.aiohttp.AIOHTTPService function in aiomisc

To help you get started, we’ve selected a few aiomisc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aiokitchen / aiomisc / tests / test_entrypoint.py View on Github external
assert TestService.DATA
    assert TestService.DATA == [b'hello server\n']


def test_aiohttp_service_create_app():
    with pytest.raises(TypeError):
        class _(AIOHTTPService):
            def create_application(self):
                return None

    class _(AIOHTTPService):
        async def create_application(self):
            return aiohttp.web.Application()


class AIOHTTPTestApp(AIOHTTPService):
    async def create_application(self):
        return aiohttp.web.Application()


def test_aiohttp_service_without_port_or_sock(aiomisc_unused_port):
    with pytest.raises(RuntimeError):
        AIOHTTPService()


def test_aiohttp_service(aiomisc_unused_port):
    @aiomisc.threaded
    def http_client():
        conn = http.client.HTTPConnection(
            host='127.0.0.1',
            port=aiomisc_unused_port,
            timeout=1
github aiokitchen / aiomisc / tests / test_entrypoint.py View on Github external
def test_aiohttp_service_without_port_or_sock(aiomisc_unused_port):
    with pytest.raises(RuntimeError):
        AIOHTTPService()
github aiokitchen / aiomisc / tests / test_entrypoint.py View on Github external
def test_aiohttp_service_create_app():
    with pytest.raises(TypeError):
        class _(AIOHTTPService):
            def create_application(self):
                return None

    class _(AIOHTTPService):
        async def create_application(self):
            return aiohttp.web.Application()
github aiokitchen / aiomisc / aiomisc / service / aiohttp.py View on Github external
)

        await self.runner.setup()

        self.site = await self.create_site()

        await self.site.start()

    async def stop(self, exception: Exception = None):
        try:
            await self.site.stop()
        finally:
            await self.runner.cleanup()


class AIOHTTPSSLService(AIOHTTPService):
    def __init__(self, cert: PathOrStr, key: PathOrStr, ca: PathOrStr = None,
                 address: str = None, port: int = None, verify: bool = True,
                 sock: socket.socket = None, shutdown_timeout: int = 5,
                 require_client_cert: bool = False, **kwds):

        super().__init__(
            address=address, port=port, sock=sock,
            shutdown_timeout=shutdown_timeout, **kwds
        )

        self.__ssl_options = cert, key, ca, verify, require_client_cert

    async def create_site(self):
        return SockSite(
            self.runner, self.socket,
            shutdown_timeout=self.shutdown_timeout,