Skip to content

matterkkila/pykestrel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Python Kestrel library

This is a simple client library for the kestrel queue system. It supports the entire documented protocol.

This library extends the Client class in the python-memcached library to add support for the non-memcache calls that kestrel supports like: config, reload, and shutdown.

WARNING!!!

You should only send strings through to the queue, if not the python-memcached library will serialize these objects and since kestrel ignores the flags supplied during a set operation, when the object is retrieved from the queue it will not be unserialized.

Examples

Adding an job to the queue:

import kestrel

q = kestrel.Client(servers=['127.0.0.1:22133'])
q.add('test_queue', 'some test job')
q.close() # disconnect the client

Read a job from the queue:

job = q.get('test_queue')

Peek at the next job in line:

job = q.peek('test_queue')

Reliably read a set of jobs from the queue:

while True:
    job = q.next('test_queue', timeout=10) # marks the last job as complete and gets a new one, also waits 10 seconds if no jobs are currently in the queue
    if job is not None:
        try:
            #process job
        except:
            q.abort('test_queue') # mark the job as failed.

q.finish('test_queue') # mark the last job a complete

About

A python library for the kestrel queue system

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages