Created
July 15, 2018 14:32
-
-
Save mikeengland/af020bfddfc60d97768e2a990ed888a3 to your computer and use it in GitHub Desktop.
Beanstalkd basic consumer/producer example using pystalkd
This file contains hidden or 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 pystalkd.Beanstalkd import Connection | |
conn = Connection(host='127.0.0.1', port=11300) | |
# watch the queue1 tube | |
conn.watch('queue1') | |
# stop watching the default tube | |
conn.ignore('default') | |
while True: | |
# block until a job is sent on the queue | |
job = conn.reserve() | |
# This is run when a job is found - perform processing here | |
print(job.job_id, job.body) | |
# Remove the job from beanstalkd once processing is completed | |
job.delete() |
This file contains hidden or 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 pystalkd.Beanstalkd import Connection | |
conn = Connection(host='127.0.0.1', port=11300) | |
# The queue to sent a message on | |
conn.use('queue1') | |
# job times out and is put back on queue after 4 hours | |
# A priority can be between 0 and 4,294,967,295 - 0 is the most urgent | |
conn.put('hello world', priority=0, ttr=14400) |
This file contains hidden or 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
pystalkd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment