Name | pyrunnable JSON |
Version |
1.0.0
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-09-04 14:20:59 |
maintainer | nbdy |
docs_url | None |
author | nbdy |
requires_python | >=3.8 |
license | MIT License |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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
```shell script
pip install pyrunnable
```
### ... use it
```python
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()
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pyrunnable",
"maintainer": "nbdy",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "nbdy",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/5c/72/f710dd96acbbc4179042aa818755ca8865957792057124615b3019316e01/pyrunnable-1.0.0.tar.gz",
"platform": null,
"description": "# pyrunnable\n\na wrapper around threading.Thread with convenience functions like\n\n- on_start (called after starting the runnable with .start)\n- on_stop (called after stopping the runnable with .stop)\n- work (executed cyclically until .stop is called)\n\nthat you can override, as well as\n\n- stop\n\nwhich i was missing in threading.Thread\n\n## how to...\n\n### ... install\n\n```shell script\npip install pyrunnable\n```\n\n### ... use it\n\n```python\nfrom pyrunnable import Runnable\nfrom time import sleep\n\nclass ThreadedObject(Runnable):\n def on_start(self):\n print(\"starting\")\n \n def work(self):\n print(\"working\")\n sleep(0.2)\n\n def on_stop(self):\n print(\"stopping\")\n\no = ThreadedObject()\ntry:\n o.start()\n o.join() # Runnable inherits threading.Thread\nexcept KeyboardInterrupt:\n o.stop()\n```\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": null,
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/nbdy/pyrunnable",
"Issues": "https://github.com/nbdy/pyrunnable/issues",
"Repository": "https://github.com/nbdy/pyrunnable.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5c72f710dd96acbbc4179042aa818755ca8865957792057124615b3019316e01",
"md5": "2b047e0c4682333e26daef7826af0547",
"sha256": "3a9bbd8575b63f2363f810f4717f0985e38c66d07a1d43fa8c0848443302d76e"
},
"downloads": -1,
"filename": "pyrunnable-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "2b047e0c4682333e26daef7826af0547",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 2466,
"upload_time": "2024-09-04T14:20:59",
"upload_time_iso_8601": "2024-09-04T14:20:59.151204Z",
"url": "https://files.pythonhosted.org/packages/5c/72/f710dd96acbbc4179042aa818755ca8865957792057124615b3019316e01/pyrunnable-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-04 14:20:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nbdy",
"github_project": "pyrunnable",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyrunnable"
}