Skip to main content

tornadoist2

Installation

pip install tornadoist2

tornadoist -currently- provides Mixins to execute code outside tornado.ioloop.IOLoop to avoid blocking. These are:

  • CeleryMixin: Celery Tasks

  • ProcessMixin: Functions in separate process

Both support results, avoids polling or timeouts. More info below.

Demo app included. (Celery with mongodb:// preconfigured in demo app)

CeleryMixin

CeleryMixin is a Mixin class to use with tornado.web.RequestHandler that provides a Tornado-like interface to running Celery tasks on TornadoServer.

HowTO

Using tornado.gen

from tornado import web, gen
from tornadoist2 import CeleryMixin

class CeleryHandler(tornado.web.RequestHandler, CeleryMixin):
    @web.asynchronous
    @gen.engine
    def get(self):
        result = yield gen.Task(self.add_task, some_task, 'somearg')
        self.write('Hello %s World!' % result)
        self.finish()

Or using explicit callback

class CeleryHandler(tornado.web.RequestHandler, CeleryMixin):
    @tornado.web.asynchronous
    def get(self):
        self.add_task(some_task, callback=self._on_result)

    def _on_result(self, result):
        do_something_with_result(result)
        self.finish()

ProcessMixin

ProcessMixin is a Mixin class to use with tornado.web.RequestHandler that provides a Tornado-like interface to running functions with multiprocessing.Process outside IOLoop.

HowTO

Using tornado.gen

from tornado import web, gen
from tornadoist import ProcessMixin

class ProcessHandler(tornado.web.RequestHandler, ProcessMixin):
    @tornado.web.asynchronous
    @tornado.gen.engine
    def get(self):
        result = yield tornado.gen.Task(self.add_task, my_blocking_function,
                                        'somearg', some_kwarg=42)
        self.write('Hello Process World! %s' % result)
        self.finish()
License

Apache License, Version 2.0

Metadata

Release files for tornadoist2 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tornadoist2 0.2.1
File Size Uploaded Provenance Actions
tornadoist2-0.2.1.tar.gz 4.3 kB Without provenance Details for tornadoist2-0.2.1.tar.gz

Release files / tornadoist2-0.2.1.tar.gz

Download URL tornadoist2-0.2.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
921baeee39774233385b112ae8f038963c630291afcf37bca6c58fc0e3d2943e
BLAKE2b-256 checksum
How to use checksums
cd5fa521d3f2d9a4369efe5058dbb34c4c68bed82df473dc55e62155aaf9bc25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for tornadoist2 0.2.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page