No project description provided
Project description
pyrunnable
a wrapper around threading.Thread with convenience functions like
- on_start (called after starting the runnable with .start)
- on_stop (called after stopping the runnable with .stop)
- work (executed cyclically until .stop is called)
that you can override, as well as
- stop
which i was missing in threading.Thread
how to...
... install
pip install pyrunnable
... use it
from pyrunnable import Runnable
from time import sleep
class ThreadedObject(Runnable):
def on_start(self):
print("starting")
def work(self):
print("working")
sleep(0.2)
def on_stop(self):
print("stopping")
o = ThreadedObject()
try:
o.start()
o.join() # Runnable inherits threading.Thread
except KeyboardInterrupt:
o.stop()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyrunnable-1.0.0.tar.gz
(2.5 kB
view hashes)