Created
November 30, 2021 04:53
-
-
Save bannsec/3eaf2520ea783c571bd419a75c0854c4 to your computer and use it in GitHub Desktop.
python await input
This file contains 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
import asyncio | |
from concurrent.futures import ThreadPoolExecutor | |
async def ainput(prompt: str = ''): | |
with ThreadPoolExecutor(1, 'ainput') as executor: | |
return (await asyncio.get_event_loop().run_in_executor(executor, input, prompt)).rstrip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment