Limit response time of a function

1

I made a script in python 3 that performs speed tests on my internet every 60 seconds and writes these results to a .txt file.

Within this script I have a function called get_results which is the function responsible for performing the internet speed test and returning a dict with the results obtained. > But if during my speed test my connection will drop the speed test does not end and my program keeps crashing, forcing me to manually stop it.

What I would like to do is to set a timeout for the return of this get_results function and if at the stipulated time it did not return anything it would be interrupted and the script would continue with the normal wait stream plus 60 seconds to perform the new test.

Code  Source in GitHub Gist

    
asked by anonymous 15.12.2017 / 02:53

0 answers