Skip to main content

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 files for threadactive 1.0.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 threadactive 1.0.1
File Size Uploaded
threadactive-1.0.1.zip 6.5 kB Details

Release files / threadactive-1.0.1.zip

Download URL threadactive-1.0.1.zip
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
53a23a415c0ac1224d3e923b4064b8b00dacf585ddc94211e2872ad3c6b212be
BLAKE2b-256 checksum
How to use checksums
6863827ca1a5492ef98a1c5afa564f944e80ec5a2748aea79ef5622aed0991bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

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