Totoro
Celery integration with Tornado.
Installation
You can install Totoro either via the Python Package Index (PyPI) or from source.
To install using pip, simply:
$ sudo pip install totoro
or alternatively (you really should be using pip though):
$ sudo easy_install totoro
or from source:
$ sudo python setup.py install
Totoro can only support AMQP(RabbitMQ) by default. To use the Redis, you can specify the requirements on the pip comand-line by using brackets.
$ sudo pip install totoro[redis]
Hello, world
Here is a simple “Hello, world!” example for calling celery tasks from Tornado RequestHandler:
#!/usr/bin/env python
import tornado.httpserver
import tornado.ioloop
import tornado.web
from tornado import gen
import totoro
from totoro.test.celery_tasks import tasks
class MainHandler(tornado.web.RequestHandler):
@gen.coroutine
def get(self):
response = yield gen.Task(tasks.echo.apply_async, args=['Hello world!'])
self.write(response.result)
def main():
totoro.setup_producer()
application = tornado.web.Application([
(r"/", MainHandler),
])
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8888)
tornado.ioloop.IOLoop.instance().start()
if __name__ == "__main__":
main()
To run celery worker for the example:
$ python -m totoro.test.runtasks worker -l INFO
Configuration and defaults
TOTORO_AMQP_CONNECTION_POOL
New in version 0.1.2
The setting must a dict that used to configure the AMQP(RabbitMQ) connection pool. It supporting the following keys:
max_idle_connections - Max number of keeping connections. Defaults to 3.
max_open_connections - Max number of opened connections, 0 means no limit. Defaults to 10.
max_recycle_sec - How long connections are recycled. Defaults to 3600.
Example configuration:
celery = Celery("totoro_celery_tasks")
celery.conf.update(
BROKER_URL='amqp://guest:guest@localhost:5672//',
CELERY_TASK_SERIALIZER='json',
CELERY_ACCEPT_CONTENT=['json'], # Ignore other content
CELERY_RESULT_SERIALIZER='json',
CELERY_TIMEZONE='Asia/Shanghai',
CELERY_ENABLE_UTC=True,
TOTORO_AMQP_CONNECTION_POOL={
'max_idle_connections': 1,
'max_open_connections': 10,
'max_recycle_sec': 3600
},
)
Tests
To run the tests for the AMQP(broker/backend):
$ python -m totoro.test.runtasks worker -l INFO
$ python -m totoro.test.runtests
To run the tests for the AMQP broker with the Redis backend:
$ CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0 python -m totoro.test.runtasks worker -l INFO
$ CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0 python -m totoro.test.runtests
To run the tests for the Redis(broker/backend):
$ BROKER_URL=redis://127.0.0.1:6379/0 CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0 python -m totoro.test.runtasks worker -l INFO
$ BROKER_URL=redis://127.0.0.1:6379/0 CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0 python -m totoro.test.runtests
Metadata
Release files for totoro 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| totoro-0.1.3.zip | 24.1 kB | Without provenance | Details for totoro-0.1.3.zip |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| totoro-0.1.3-py27-none-any.whl | Python 2.7 | none | any | Details for totoro-0.1.3-py27-none-any.whl |
Total release size: 40.3 kB
Release files / totoro-0.1.3.zip
| Download URL | totoro-0.1.3.zip |
|---|---|
| Size | 24.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
219e33d694eaf452d6153027b31a069e0036a34554c3ee792a0a060ea324aa09
|
|
BLAKE2b-256 checksum How to use checksums |
005b9f0f159bbe09512682b2b1954e5da11507a158ec0d87c44ff8386efc704c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / totoro-0.1.3-py27-none-any.whl
| Download URL | totoro-0.1.3-py27-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 2.7 |
|
SHA-256 checksum How to use checksums |
56d2967f26df930f1fe8a08021213a2880cefcacc4d046b375a13482860ed210
|
|
BLAKE2b-256 checksum How to use checksums |
b6bf4dd368efe73606be5ecd8e2d1fbbca40a7e8679ae04e4d02dd12fd6e4eaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for totoro 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.