stoppable and restartable thread simply using an event
Project description
```python
def func(stop_event):
while True:
if stop_event.is_set():
break
# do something
thread = StoppableThread(target=func)
thread.start()
# ...
thread.stop()
# thread.stopped() == True
thread = ReStartableThread(target=func, event_name='stop_event') # can specify the parameter's name
thread.start()
# ...
thread.stop()
# ...
thread.start()
# ...
thread.stop()
# ...
```
def func(stop_event):
while True:
if stop_event.is_set():
break
# do something
thread = StoppableThread(target=func)
thread.start()
# ...
thread.stop()
# thread.stopped() == True
thread = ReStartableThread(target=func, event_name='stop_event') # can specify the parameter's name
thread.start()
# ...
thread.stop()
# ...
thread.start()
# ...
thread.stop()
# ...
```
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.3.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for sine.threads-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3c8214e104d11583f7009e9c4e37a9247bcc4a5d47e6b5969d9e9ee380c454f |
|
MD5 | 55d063468f82f5558487ad47ca3a8554 |
|
BLAKE2b-256 | 9eb7408fef02214f1e3a9e68b22f1d53f105c298e6186bf71c35f6f9e18cff8f |