Last active
July 18, 2019 10:33
-
-
Save afonasev/bf47d05ffd9dae3b3e2d709744b76350 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def threadpool(func: FUNC) -> FUNC: | |
@wraps(func) | |
def wrapper(*args: Any, **kwargs: Any) -> Awaitable[Any]: | |
loop = get_event_loop() | |
callback = partial(func, *args, **kwargs) | |
return loop.run_in_executor(None, callback) | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment