GithubHelp home page GithubHelp logo

pombredanne / lightqueue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aphan/lightqueue

0.0 1.0 0.0 125 KB

A lightweight Python job queue with multiprocessing support

License: MIT License

lightqueue's Introduction

lightqueue

lightqueue is a lightweight job queue that processes jobs (Python function calls) from a queue located inside a Redis database. There is also support for processing multiple jobs at once.

To install it:

$ pip install lightqueue

After you have lightqueue (and Redis) installed, you are ready to start queueing jobs. Say you have a function like this in a module called mymodule

def myfunc(num):
  print sum([x for x in range(num)])

To add the execution of this function as a job into lightqueue:

>>> from lightqueue.queue import Queue
>>> from mymodule import myfunc
>>> q = Queue()
>>> q.enqueue(myfunc, 9999) # add the job myfunc(9999) to the queue
>>> q.enqueue(myfunc, 1234567) # add the job myfunc(1234567) to the queue

To start processing these jobs, type this in a shell prompt:

$ lightqueue start

If the lightqueue process has to shut down in the middle of executing the job, it will place the job back onto the front of the queue.

Change db server

By default, lightqueue adds jobs to and processes jobs from the Redis server located at localhost:6379 on db=0. To change any of these settings:

>>> Queue q = Queue(host='myredishost', port=7323, db=4)

Then give the lightqueue process the same settings:

$ lightqueue start -host myredishost -port 7323 -db 4

Parallel Processing

By default, lightqueue processes one job from the queue at a time. To process more than one job at once (let's say 4), start up lightqueue with the following command-line args:

$ lightqueue start -e parallel -workers 4

This uses the Python multiprocessing module so be aware of all of the usual caveats of parallel processing.

lightqueue's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.