This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

collective.futures

This is a collective package for providing yet another way to do asynchronous (non-blocking) processing on Plone.

This time we speak in terms of promises and futures: promises are asynchronously run functions, which provide their results as requested futures for add-on your code.

A major differences for any other alternatives is that this does not require any additional services, but requires only Plone running on top of a Zope instance.

A major limitation is that the asynchronously executed code cannot access the database in any way (or you may face unexpected consequences). Also, this brings no benefits with HAProxy and fixed amount current requests per instance.

Example

from Products.Five.browser import BrowserView

from collective import futures


def my_async_task(*args):
    # a lot of time consuming async processing
    return u'my asynchronously computed value'


class MyView(BrowserView):

    def __call__(self, *args):
        try:
            return futures.result('my_unique_key')
        except futures.FutureNotSubmittedError:
            futures.submit('my_unique_key', my_async_task, *args)
            return u'just a placeholder value'

or

from Products.Five.browser import BrowserView

from collective import futures


def my_async_task(*args):
    # a lot of time consuming async processing
    return u'my asynchronously computed value'


class MyView(BrowserView):

    def __call__(self, *args):
        return futures.resultOrSubmit(
            'my_unique_key', u'placeholder value', my_async_task, *args)

Explanation

This package uses approach, which kind of splits a single request into two separate passes:

Whenever some add-on code requires a value to be computed asynchronously, it tries to request for a named future result at first and only then submits a promise function to compute result for that future.

If any futures are submitted, the initial response is never published, but instead the current transaction is aborted and the submitted promise functions are executed in parallel threads separate from the default Zope threads (or even in parallel processes) and their return values are collected (see also the documentation of concurrent.futures in Python).

When all promise functions have been resolved, the original request is cloned, resolved values are set as futures and a new internal request is dispatched.

After this second pass, the add-on code can use the now available futures, not submit more futures, and finally, the response is published all the way to the browser.


For more background information: http://datakurre.pandala.org/2014/05/asynchronous-stream-iterators-and.html

Changelog

0.9.1 (2016-05-25)

  • Fix issue where resolved futures were not passed for nested requests [datakurre]

0.9.0 (2014-10-23)

  • First release.
Release History

Release History

0.9.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.9.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
collective.futures-0.9.1.tar.gz (11.1 kB) Copy SHA256 Checksum SHA256 Source May 25, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting