Ejemplo n.º 1
0
    async def methodNameStream(self) -> AsyncGenerator[str, None]:
        method_name: str = get_context().method_name

        async def gen() -> AsyncGenerator[str, None]:
            for char in method_name:
                yield char

        return gen()
Ejemplo n.º 2
0
 async def readHeader(self, key: str) -> str:
     return get_context().read_headers[key]
Ejemplo n.º 3
0
 async def getRequestTimeout(self) -> float:
     ctx = get_context()
     return ctx.request_timeout
Ejemplo n.º 4
0
 async def getRequestId(self) -> str:
     ctx = get_context()
     return ctx.request_id
Ejemplo n.º 5
0
 async def getMethodName(self) -> str:
     ctx = get_context()
     return ctx.method_name
Ejemplo n.º 6
0
 async def getName(self) -> str:
     ctx = get_context()
     ctx.set_header("contextvar", "true")
     return "Testing"
Ejemplo n.º 7
0
 async def invert(self, value: bool) -> bool:
     ctx = get_context()
     if "from client" in ctx.read_headers:
         ctx.set_header("from server", "with love")
     return not value
Ejemplo n.º 8
0
 async def getName(self) -> str:
     if sys.version_info[:2] >= (3, 7):
         ctx = get_context()
         ctx.set_header("contextvar", "true")
     return "Testing"