Created
August 30, 2013 09:21
-
-
Save tonijz/6387986 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import task | |
from twisted.internet import reactor | |
import time | |
def say_hello(): | |
rand = time.time() | |
x = 0 | |
while True: | |
print "#%s Hey %s" % (x, rand) | |
time.sleep(1) | |
x += 1 | |
if x == 10: | |
return True | |
def other_task(): | |
rand = time.time() | |
x = 0 | |
while True: | |
print "#%s Other Task %s" % (x, rand) | |
time.sleep(1) | |
x += 1 | |
if x == 10: | |
return True | |
task_1 = task.LoopingCall(say_hello) | |
#task_1.start(1) | |
reactor.callFromThread(task_1.start, 1) | |
task_2 = task.LoopingCall(other_task) | |
#task_2.start(1) | |
reactor.callFromThread(task_2.start, 1) | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment