Skip to main content

stoppable and restartable thread simply using an event

Project description

# Example

```python
from sine.threads import *

def func(stop_event):
while 1:
if stop_event.is_set():
break
# do your work

thread = StoppableThread(target=func)
thread.start()
# ...
thread.stop()
# thread.stopped() == True
thread.join()


thread = ReStartableThread(target=func, event_name='stop_event') # can specify the parameter's name
thread.start()
# ...
thread.stop()
thread.join()
# ...
thread.start()
# ...
thread.stop()
thread.join()
# ...
```


# Changelog

#### v0.1.5, 2018-9-11

* fix logic about join(), when directly join() without start() but stop()

#### v0.1.4, 2018-6-7

* ReStartableThread support join the old thread instance
* fix: ReStartableThread.start always creates new instance
* *improve comment and change to English*
* *change directory structure and update setup.py*
* *add tests.py*


Project details


Download files

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

Files for sine.threads, version 0.1.5
Filename, size File type Python version Upload date Hashes
Filename, size sine.threads-0.1.5-py2.py3-none-any.whl (6.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size sine.threads-0.1.5.tar.gz (5.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page