Skip to content

Instantly share code, notes, and snippets.

@tonijz
Created August 30, 2013 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonijz/6387986 to your computer and use it in GitHub Desktop.
Save tonijz/6387986 to your computer and use it in GitHub Desktop.
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