vendredi 31 juillet 2015

Testing a loop that repeats itself every 10 seconds

I have a code that repeats itself every 10 seconds, but I can't test it for a long time because my powershell keeps on hanging and the code just stops for no particular reason (the code is running but it doesn't give out results). Is there a way to test the code, or safely running it without it being interrupted? I tried to search but it seems that a library like Unittest will just crash along with my code due to windowshell if I want to run it for lets say a day. Because it usually hangs just a few hours after I start testing manually.

The code is something like this:

import time
import requests
while True:
    getting = requests.get(some_url)
    result = getting. json()
    posting = requests.post(another_url,headers,json=result)
    time.sleep(10)

Thank you for your help.

Aucun commentaire:

Enregistrer un commentaire