Is your feature request related to a problem? Please describe.
It seems like sync libs are being used and tossed onto OS threads, are there any plans to use asyncio libs? e.g. aiomqtt instead of paho mqtt https://github.com/empicano/aiomqtt
|
def emulate_async(fn): |
|
"""Returns a coroutine function that calls a given function with emulated asynchronous |
|
behavior via use of multithreading. |
|
|
|
Can be applied as a decorator. |
|
|
|
:param fn: The sync function to be run in async. |
|
:returns: A coroutine function that will call the given sync function. |
|
""" |
|
|
|
@functools.wraps(fn) |
|
async def async_fn_wrapper(*args, **kwargs): |
|
loop = asyncio.get_running_loop() |
|
|
|
# Run fn in default ThreadPoolExecutor (CPU * 5 threads) |
|
return await loop.run_in_executor(None, functools.partial(fn, *args, **kwargs)) |
|
|
|
return async_fn_wrapper |
Describe the solution you'd like
Usage of asyncio.
Describe alternatives you've considered
If I had to I suppose I would just implement the calls manually.
Is your feature request related to a problem? Please describe.
It seems like sync libs are being used and tossed onto OS threads, are there any plans to use asyncio libs? e.g. aiomqtt instead of paho mqtt https://github.com/empicano/aiomqtt
azure-iot-sdk-python/azure-iot-device/azure/iot/device/common/async_adapter.py
Lines 16 to 33 in e75d1c2
Describe the solution you'd like
Usage of asyncio.
Describe alternatives you've considered
If I had to I suppose I would just implement the calls manually.