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.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*
```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.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.
Source Distribution
sine.threads-0.1.4.tar.gz
(5.4 kB
view hashes)
Built Distribution
Close
Hashes for sine.threads-0.1.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57799c4b81de77c799e641888a5d48f2887492f75b764fa8e471f8b17b9f4d9f |
|
MD5 | 02688ea2306a19876f382e65135e3418 |
|
BLAKE2b-256 | 0be73ae89b3629d70e11b46dd8ca01de0e684d2d8e0bb4cc23620b8dcd88c91a |