Click here to Skip to main content
15,889,339 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey guys
i'm wondering on how to let a function to work for a certin amount of time
i have been building a web crawler to gather links from a certin page and one of the functions i need it to work for amount of time then goes to sleep for another amount of time then work etc.....
any idea here

What I have tried:

i tried sleep function and it's only delaying the work
Posted
Updated 16-Aug-16 22:04pm
v2

1 solution

You just need to capture the time when your function starts, and then periodically check whether it has reached its time limit. you then sleep for the allotted rest time and then repeat the whole process. See 15.3. time — Time access and conversions — Python 2.7.12 documentation[^].
 
Share this answer
 
Comments
pyoder 19-Aug-16 5:12am    
can't run it again with this method
Richard MacCutchan 19-Aug-16 5:32am    
Is that supposed to mean something?
pyoder 20-Aug-16 20:54pm    
thanks any way ,, i found how to do it with threads

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900