0

I have two functions: func1 and func2.

Both of them collect & write steaming data. I would like func1 to run for approximately 1 hour and then safely stop. It will then take a break for x minutes using time.sleep, and then start executing func2 which also runs for an hour.

The looping would look like: func1-sleep-func2-sleep-func1.

Ive learned about the Threading and Scheduling module, but I'm unsure on how to approach this problem. Any help would be appreciated.

Mo.Y
  • 15
  • 2
  • 1
    Possible duplicate of [Timeout on a function call](http://stackoverflow.com/questions/492519/timeout-on-a-function-call) – Barmar Mar 31 '17 at 04:47
  • Its going to depend on what the functions are doing. If they are in loops, you may be able to have them check how long they've run then exit. If they are writing to sockets you could potentially abort those sockets. If they are enumerating a file, you could close that file. There are many possibilities. – tdelaney Mar 31 '17 at 05:05
  • functions are collecting twitter streaming data, func1 is collecting one percent sample data. Func2 is collecting filter data with specific keywords, lets say func1 generates 25 GB file, so can we do something like if file size is greater than 25GB stop executing that function and run next function. – Adam Claypool Mar 31 '17 at 05:24
  • Read about: https://docs.python.org/2/library/threading.html#event-objects – stovfl Mar 31 '17 at 08:33

0 Answers0