Git Product home page Git Product logo

nibbler's Introduction

nibbler

celery + rabbitMQ task handling

setup

  1. Install RabbitMQ

    This will also start RabbitMQ with default configuration.

    $ apt-get install rabbitmq-server
  2. Install Python dependencies (or use the provided Pipfile and Pipfile.lock):

# using pipenv
$ pipenv install --dev

# or
$ pip install celery flower

usage

  1. Start the celery worker:
$ celery -A nibbler.app worker
  1. In another terminal, enter a Python shell in your virtual environment.

  2. Submit a job to RabbitMQ and observe its completion:

Let's get a random image from httpbin:

>>> from nibbler import app
>>> resp = app.download.delay(  # delay submits to RabbitMQ (async)
...     'https://httpbin.org/image/jpeg',
...     'random-img'
... )

And then inspect the task. See also resp.traceback, or the Celery terminal itself.

>>> resp.ready()  # check whether task has finished
True
>>> resp.status
'SUCCESS'
>>> app.list_files()  # watch out - this is a synchronous call, just for brevity
['random-img']

Let's perform the list_files task properly now - i.e., also asynchronously:

>>> lf = app.list_files.delay()
>>> lf.ready()
True
>>> # without a timeout kwarg, the client waits for the task to finish synchronously
>>> lf.get(timeout=1)
['random-img']

management & monitoring

flower

Access flower in a browser, at the host & port running it.

flower can be initialised in itself,

$ flower -A nibbler.app --port=5555

or through celery in order to specify additional inline configurations:

$ celery flower -A nibbler.app --address=127.0.0.1 --port=5555
$ celery flower -A nibbler.app --broker=amqp://guest:guest@localhost:5672//

rabbitMQ

Access rabbitmq's management interface in a browser, at the host & port (15672 by default) running it.

First, confirm the management interface is enabled, and (if not) run the server again to load it as a plugin:

$ rabbitmq-plugins enable rabbitmq_management
$ rabbitmq-server -detached

nibbler's People

Contributors

oaao avatar

Watchers

 avatar  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.