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

Summary

A Python persistent process pool for use with Twisted. Provides the ability to run Python callables asynchronously within a pool of persistent processes, as long as the callable, its arguments, and its return value are all picklable.

Installing

pip install txpool

or

python setup.py install

Examples

Here are some simple examples to give you the idea:

import glob
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
import txpool

pool = txpool.Pool()

@inlineCallbacks
def main():
    result = yield pool.apply_async(glob.glob, ('*.pdf',))
    print result
    reactor.stop()

reactor.callWhenRunning(main)
reactor.run()

The callable can instead be specified as a string, using dotted notation to specify the full path to the callable.

from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
import txpool

pool = txpool.Pool()

@inlineCallbacks
def main():
    # You can provide an optional timeout (in seconds) for the call
    # (the default is None).
    try:
        result = yield pool.apply_async('glob.glob', ('*.pdf',), timeout=5)
    except PoolTimeout as e:
        result = e
    print result
    reactor.stop()

reactor.callWhenRunning(main)
reactor.run()

The txpool.Pool class can be explicitly sized, asked to log its actions, and/or given a custom name.

import logging
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, gatherResults
import txpool

logger = logging.getLogger('example')
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)

pool = txpool.Pool(size=5, log=logger, name='twisting-by-the-pool')

@inlineCallbacks
def main():
    calls = ('math.factorial',) * 5
    args = [(n,) for n in range(150780, 150785)]

    # You can wait until the pool is at full-strength (providing an
    # optional timeout if desired), but it's not required before
    # calling the "apply_async" method.  Jobs are queued until a
    # worker process is available.
    try:
        yield pool.on_ready(timeout=10)
    except PoolTimeout as e:
        results = e
    else:
        results = yield gatherResults(map(pool.apply_async, calls, args))

    print results

    try:
        # You can gracefully close the pool, which ensures all jobs
        # already queued are completed before shutting down...
        yield pool.close(timeout=10)
    except PoolTimeout as e:
        print e
        # ...or you can use force and immediately send SIGKILL to each
        # process in the pool.
        yield pool.terminate(timeout=10)

    reactor.stop()

reactor.callWhenRunning(main)
reactor.run()
Release History

Release History

0.9

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

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
txpool-0.9-py2-none-any.whl (11.7 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Jan 28, 2015
txpool-0.9.tar.gz (10.2 kB) Copy SHA256 Checksum SHA256 Source Jan 28, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development 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