Home>

I need that a person would have been given 5 seconds to enter any text. If in 5 seconds it does not do this, then the execution of the program should stop. But, the program stops only if you have time to enter, if you expire for 5 seconds, the program continues to work.

Import asyncio
From Aioconsole Import Ainput
ASYNC DEF MAIN ():
    ASYNC DEF INPUT ():
        x= await ainput ()
Try:
    await asyncio.wait_for (INPUT (), TimeOut= 5)
Except Asyncio.Timeouterror:
    PRINT ('TIMEOUT')
LOOP= ASYNCIO.GET_EVENT_LOOP ()
loop.run_until_complete (main ())

Perhaps Defect Ainput.

eri2021-05-05 08:03:43

What is your python version and operating system? Python 3.9 Linux -Your code works fine

eri2021-05-05 09:38:46