Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • BackTrack 5 R2
  • Wine 1.4 / 1.5.5
  • Mozilla Firefox 12...
  • Ubuntu 11.04
  • Angry Birds 1.1.2.1
  • Ubuntu 10.04.4 LTS
  • Linux Kernel 3.4
  • Ubuntu Manual 10.10
  • Adobe Flash Player...
  • Pidgin 2.10.4
  • Home > Linux > Programming > Libraries

    Torque 0.4.5

    Download button

    No screenshots available
    Downloads: 337  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    James Arthur | More programs
    Public Domain / FREE
    February 8th, 2010, 17:04 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Torque description

    A web hook task queue based on tornado and redis

    Torque is a web hook task queue based on tornado and redis. It's intended to provide a similar pattern to Google App Engine's taskqueue.

    To use Torque, you need to run a redis database, a console script that exposes a Tornado web application and one process per task queue. You can then add tasks to one or more queues, either using the python client api that torque provides or via an HTTP api (or indeed by adding them directly to the database).

    Tasks consist of a url and some params. When a task is executed, torque will post the params to the url. If the task errors, it backs off steeply until it errors too many times, at which point it's deleted.

    Tasks are stored in a redis SortedSet. Tornado is used to execute tasks asyncronously, without blocking.

    Install:

    Install the redis and Tornado dependencies. (n.b.: see ./etc/redis.tiger.patch if, like me, you're still using OSX Tiger). Then install the torque egg:

    python setup.py install

    Run:

    Run redis:

    ./redis-server

    Start the Tornado application:

    ./bin/torque-serve

    Start the task queue:

    ./bin/torque-process

    See --help against either of the torque console scripts for a list of configuration options. For example, to run a second queue called foobar, you might use:

    ./bin/torque-process --queue_name=foobar

    Use:

    To add a task to the queue, post to /add_task with two params:

     * url which is the url to the webhook you want the task to request
     * params which is a json encoded dictionary of the params you want to post to the webhook you're requesting

    An example in python (with the Tornado application available on localhost, running on port 8889) would be:

    import json
    import urllib

    mytask = {
     'url': 'http://mywebservice.com/hooks/do/foo',
     'params': json.dumps({'foo', 'somevalue', 'baz': 99})
    }
    target_url = 'http://localhost:8889/hooks/add'
    urllib.urlopen(target_url, urllib.urlencode(mytask))


    This queued a POST request to http://mywebservice.com/hooks/do/foo with the params foo=somevalue and baz=99 to be made as soon as possible.

    You can do something similar using any programming language that can make url requests. However, if you are using python, you can use the client api that torque provides:

    from torque.client import add_task

    add_task(url='http://mywebservice.com/hooks/do/foo', params={'a': 1})

    Note that this doesn't require json encoding the params. You can specify a delay for the task, so that it's executed after (but not necessarily at) a number of seconds:

    add_task(url='...', params={...}, delay=20) # will execute after 20 seconds

    Individual tasks backoff exponentially if they error, upto a maximum backoff delay that's configurable as --max_task_delay, until they error --max_task_errors times (at which point they get deleted).

    See the source code for more info and options, or just run it and use it.


    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    redis database | Python library | Tornado | redis | database



    HTML code for linking to this page:


    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM