forked from loafle/openapi-generator-original
* python: remove non-async code path from the aiohttp generator This removes all the non-async code from the aiohttp generator: * all the methods that should be asynchronous are marked as `async` * the `async_req` parameter is gone; calls are directly awaitables now * the async calls into a thread pool are gone and the thread pool is gone too (now useless) Closes: #15824 Closes: #5539 Related: #763 Related: #3696 * Fix empty line * remove more
20 lines
408 B
Python
20 lines
408 B
Python
# flake8: noqa
|
|
|
|
import asyncio
|
|
import random
|
|
|
|
|
|
def id_gen(bits=32):
|
|
""" Returns a n-bit randomly generated int """
|
|
return int(random.getrandbits(bits))
|
|
|
|
|
|
def async_test(f):
|
|
def wrapper(*args, **kwargs):
|
|
# coro = asyncio.coroutine(f)
|
|
coro = f
|
|
future = coro(*args, **kwargs)
|
|
loop = asyncio.get_event_loop()
|
|
loop.run_until_complete(future)
|
|
return wrapper
|