Skip to main content

AMQP based worker/master pattern framework

Project description

AMQP based RPC library for Tornado

Use cases

  • Task queue

  • Load balancing for different CPU-bound HTTP handlers

  • … other systems which involve RPC

Installation

pip install crew

Example

See the full example.

Usage

For example create your first app, and save as master.py:

import tornado.ioloop
import tornado.gen
import tornado.web
import tornado.log
import json
import tornado.options
from crew import TimeoutError, ExpirationError
from crew.master.tornado import Client

class MainHandler(tornado.web.RequestHandler):

    @tornado.gen.coroutine
    def get(self):
        resp = yield self.settings['crew'].call(None, priority=100)
        self.write(json.dumps(resp)

cl = Client()
application = tornado.web.Application(
    [
        (r"/", MainHandler),
    ],
    crew=cl,
    autoreload=True,
    debug=True,
)

if __name__ == "__main__":
    cl.connect()
    tornado.options.parse_command_line()
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

And create your first task, and save as worker.py:

# encoding: utf-8
from crew.worker import run, context, Task

@Task('test')
def long_task(req):
    context.settings.counter += 1
    return {"counter": context.settings.counter}

run(
    counter=0
)

After that run it:

$ python master.py &
$ python worker.py &
$ wait

Try to test it:

$ curl http://localhost:8888/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crew-0.9.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distributions

crew-0.9.0.macosx-10.11-x86_64.tar.gz (29.8 kB view details)

Uploaded Source

crew-0.9.0-py2.7.egg (16.1 kB view details)

Uploaded Source

crew-0.9.0-py2-none-any.whl (18.3 kB view details)

Uploaded Python 2

File details

Details for the file crew-0.9.0.tar.gz.

File metadata

  • Download URL: crew-0.9.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for crew-0.9.0.tar.gz
Algorithm Hash digest
SHA256 87167287d87ba21b2446c115ed33e69d66464cfa07e0c4bfe6b295597f4e2351
MD5 5df8c2d240052d017141ebd1bf8d2fdd
BLAKE2b-256 049afc789f3180a112422ac7617c068ec377b0e27ca09e3ff053f1685eb3f46c

See more details on using hashes here.

File details

Details for the file crew-0.9.0.macosx-10.11-x86_64.tar.gz.

File metadata

File hashes

Hashes for crew-0.9.0.macosx-10.11-x86_64.tar.gz
Algorithm Hash digest
SHA256 c3b330a4bab191a819892080ed1a12c5003d3b5740ed216af29a5c2036198486
MD5 be8b7ba01c469f37586645c84078dbe6
BLAKE2b-256 0c8cc2c0bc7735717cbc9e793550fde6657acfeb77f08c05671b6a01d0309da6

See more details on using hashes here.

File details

Details for the file crew-0.9.0-py2.7.egg.

File metadata

  • Download URL: crew-0.9.0-py2.7.egg
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for crew-0.9.0-py2.7.egg
Algorithm Hash digest
SHA256 342b024681518159490ece9e6fa2f7f5114022455b96dc64970810e6693ac069
MD5 725cf60c53b70c8814c79aafe7a8b4b7
BLAKE2b-256 6c2f0896d63f2963a26ce44f77f6a90c22592b075db2844cf6944b37fbb6355c

See more details on using hashes here.

File details

Details for the file crew-0.9.0-py2-none-any.whl.

File metadata

File hashes

Hashes for crew-0.9.0-py2-none-any.whl
Algorithm Hash digest
SHA256 38c93670c299625ef4f633b4bfb3d5fd55fc787c4dd30c1667db10be64327e1f
MD5 78cdd4992979733c29f6b3f220684b9f
BLAKE2b-256 2995c7449e86ae3bdd048c65e31f2bff273072658860e3ad3b52da20fe705fdb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page