Skip to content

Commit

Permalink
fix: async generators on python 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
standy66 committed Jul 23, 2019
1 parent 9001728 commit 1c19229
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/purerpc/server.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import sys
import inspect
import warnings
import socket
import collections
import async_generator
import functools
import async_exit_stack
from multiprocessing import Process
import logging

import anyio
import typing
import logging
from async_generator import async_generator, asynccontextmanager, yield_

from .grpclib.events import RequestReceived
from .grpclib.status import Status, StatusCode
Expand Down Expand Up @@ -98,12 +95,13 @@ def tcp_server_socket(host, port, family=socket.AF_INET, backlog=100,
return raw_socket


@async_generator.asynccontextmanager
@asynccontextmanager
@async_generator
async def _service_wrapper(service=None, setup_fn=None, teardown_fn=None):
if setup_fn is not None:
yield (await setup_fn())
await yield_(await setup_fn())
else:
yield service
await yield_(service)

if teardown_fn is not None:
await teardown_fn()
Expand Down

0 comments on commit 1c19229

Please sign in to comment.