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!

Generic stoppable thread

Project Description

qThread provides an simplified and safe way to stop long running threads. Typical uses often look like this:

# Test / Usage of the stoppable thread
class MyThreadingClass(StoppableThread):
    def __init__(self, a):
        super(MyThreadingClass, self).__init__()
        self.a = a
        self.b = "World"
        self.delay = .5 # seconds

    def startup(self):
        # Overload the startup function
        print "My Thread Starting Up..."

    def cleanup(self):
        # Overload the cleanup function
        print "My Thread Is Shutting Down..."
        # Close files, ports, etc...
        time.sleep(4)
        print "Cleanup Complete!"

    def mainloop(self):
        # Some routine to be called over and over
        # ie: reading ports or sockets
        print self.a + " " + self.b

        # Throttling needs to be done here if the
        # primary function is not blocking
        time.sleep(self.delay)
Release History

Release History

This version
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
qThread-0.1.0.tar.gz (2.6 kB) Copy SHA256 Checksum SHA256 Source Apr 12, 2013

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