Asynchronous Timer Implementation in Python -
i need implement asyncronous timer 'watch' execution of list of functions, till timer expires. problem function execution blocking call , in case how can track timer if function take long comeback.
functions = [func_1, func_2, func_3, func_n] timer = timer(30) # timer of 30 sec, example. while timer.expires(): func in functions: func() # if function runs min
i avoid multithreading , multiprocessing far possible, if multiprocessing/threading way out please provide solutions also.
what different ways in python in asynchronous behaviour can achieved.
if functions call blocking due io, can use asyncio module turn them non blocking. @ point wrap them future , set timeout completion. keep in mind timeout considering io.
if functions blocking due cpu bound jobs (while loops, long calculations) there no way achieve without using processes.
Comments
Post a Comment