-
Notifications
You must be signed in to change notification settings - Fork 0
/
rqTest.py
35 lines (29 loc) · 890 Bytes
/
rqTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
A temporary python test script to make sure RQ is working across
EC2-Heroku borders.
Sends an image over to the EC2 instance by way of RQ
Daniel Guilak <[email protected]>
"""
# For RQ stuff:
from rq import Queue
from redis import Redis
import time
import cStringIO
import roaster
# Connect to Redis instance on EC2
redisConn = Redis("ec2-54-244-145-206.us-west-2.compute.amazonaws.com", 6379)
# Connect to the queue
q = Queue(connection=redisConn) # no args implies the default queue
# New buffer
buff = cStringIO.StringIO()
# Opens temp.png and sets buffer to the beginning
buff.write(open('temp.png', 'rb').read())
buff.seek(0)
# Sends the buffer value to the queue and asks it to save
# the image on the EC2-side.
job = q.enqueue(roaster.saveImage, buff.getvalue())
# print job.result # => None
# time.sleep(10)
# print job.result
# time.sleep(10)
# print job.result