Python-Tls-Client icon indicating copy to clipboard operation
Python-Tls-Client copied to clipboard

Async

Open r1x0s opened this issue 3 years ago • 2 comments

Hi, is it possible to use it asynchronously?

r1x0s avatar Feb 15 '23 10:02 r1x0s

I've also been wondering for a long time about being able to use this asynchronously, because you won't do much synchronously.

I use decorators :

import time
import os
import asyncio
from functools import wraps, partial

def async_wrap(func):
    @wraps(func)
    async def run(*args, loop=None, executor=None, **kwargs):
        if loop is None:
            loop = asyncio.get_event_loop()
        pfunc = partial(func, *args, **kwargs)
        return await loop.run_in_executor(executor, pfunc)
    return run 

@async_wrap
def my_async_sleep(duration):
    time.sleep(duration)

MsLolita avatar Feb 19 '23 10:02 MsLolita

#68 check this

r1x0s avatar May 02 '23 08:05 r1x0s