Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A simple utility help building multithread application through message queue

Project Description

A simple utility help building multithread application through message queue.

Examples

main.py:

import time
import threading
import threadactive


class BackWorker(threadactive.Agent):
    def tick(self):
        threadactive.Agent.tick(self)
        print("[%s][%d] front" % (threading.current_thread().getName(), time.clock()) )
        self.print_in_back()
        time.sleep(1)

    @threadactive.backend
    def print_in_back(self, *args, **kwargs):
        print("[%s][%d] back" % (threading.current_thread().getName(), time.clock()) )
        if time.clock() > 3:
            self.back_to_front()

    @threadactive.frontend
    def back_to_front(self, *args, **kwargs):
        print("[%s][%d] back to front" % (threading.current_thread().getName(), time.clock()) )


bw = BackWorker()
while True:
    bw.tick()

output:

[MainThread][0] front
[Thread-1][0] back
[MainThread][1] front
[Thread-1][1] back
[MainThread][2] front
[Thread-1][2] back
[MainThread][3] front
[Thread-1][3] back
[MainThread][4] back to front
[MainThread][4] front
[Thread-1][4] back
[MainThread][5] back to front
[MainThread][5] front
[Thread-1][5] back
...
Release History

Release History

This version
History Node

1.0.1

History Node

1.0.0

History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
threadactive-1.0.1.zip (6.5 kB) Copy SHA256 Checksum SHA256 Source Jun 16, 2015

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