Skip to content

Instantly share code, notes, and snippets.

@jayd3e
Created May 31, 2012 18:51
Show Gist options
  • Save jayd3e/2845380 to your computer and use it in GitHub Desktop.
Save jayd3e/2845380 to your computer and use it in GitHub Desktop.
retools queue and worker
# queue.py run from the commandline
import time
from retools.queue import QueueManager
def insanely_slow_function(num=0):
previous = 1
for i in range(1, num):
previous = previous + i
return previous
qm = QueueManager()
while(True):
qm.enqueue('dummyapp.queue:insanely_slow_function', num=100000000)
print("I just ran!")
time.sleep(40)
#insanely_slow_function(num=100000000)
#
# Then I just call retools-worker in another terminal
#
@bbangert
Copy link

queue.py run from the commandline

import time
from retools.queue import QueueManager

def insanely_slow_function(num=0):
previous = 1
print "running job"
for i in xrange(1, num):
previous = previous + i
print "done with job"
return previous

qm = QueueManager()

if name == 'main':
while(True):
qm.enqueue('code:insanely_slow_function', num=100000000)
print("I just ran!")
time.sleep(40)

insanely_slow_function(num=100000000)

Then I just call retools-worker in another terminal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment