Skip to content

Instantly share code, notes, and snippets.

@bannsec
Created November 30, 2021 04:53
Show Gist options
  • Save bannsec/3eaf2520ea783c571bd419a75c0854c4 to your computer and use it in GitHub Desktop.
Save bannsec/3eaf2520ea783c571bd419a75c0854c4 to your computer and use it in GitHub Desktop.
python await input
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