{"id":24755060,"url":"https://github.com/francois-le-ko4la/python-multithreading","last_synced_at":"2025-08-01T13:04:33.737Z","repository":{"id":84214982,"uuid":"134393191","full_name":"francois-le-ko4la/python-multithreading","owner":"francois-le-ko4la","description":"Multithreading with Python","archived":false,"fork":false,"pushed_at":"2024-04-07T18:48:17.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-23T06:13:27.482Z","etag":null,"topics":["multithreading","python-3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/francois-le-ko4la.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-22T09:37:25.000Z","updated_at":"2023-01-23T01:31:03.000Z","dependencies_parsed_at":"2025-01-28T12:34:26.127Z","dependency_job_id":"b3a4a475-81f1-422d-a404-e6783aa22d24","html_url":"https://github.com/francois-le-ko4la/python-multithreading","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/francois-le-ko4la/python-multithreading","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francois-le-ko4la%2Fpython-multithreading","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francois-le-ko4la%2Fpython-multithreading/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francois-le-ko4la%2Fpython-multithreading/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francois-le-ko4la%2Fpython-multithreading/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francois-le-ko4la","download_url":"https://codeload.github.com/francois-le-ko4la/python-multithreading/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francois-le-ko4la%2Fpython-multithreading/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268229200,"owners_count":24217003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["multithreading","python-3"],"created_at":"2025-01-28T12:34:18.591Z","updated_at":"2025-08-01T13:04:33.688Z","avatar_url":"https://github.com/francois-le-ko4la.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pthread\n## Description:\n\nThis package provide a simple way to manage multithreading in python project.\n\n## Why:\n- Clean the main code\n- Simplify multithreading use with general objectives\n\n## Why we will never use it:\n- :x: All the code use multithreading\n- :x: We use complex mecanisme between object: sync between object or data issue\n\n## Setup:\n```shell\ngit clone https://github.com/francois-le-ko4la/python-multithreading.git\ncd python-multithreading\nmake install\n```\n\n## Test:\n```shell\nmake test\n```\n\n## Use:\n\nTake a look in the dev part.\n\n## Project Structure\n```\n.\n├── last_check.log\n├── LICENSE\n├── Makefile\n├── pictures\n│   ├── classes_pythread.png\n│   └── packages_pythread.png\n├── pythread\n│   ├── __about__.py\n│   ├── __init__.py\n│   └── thread.py\n├── README.md\n├── runtime.txt\n├── setup.cfg\n├── setup.py\n└── tests\n    ├── test_doctest.py\n    └── test_pycodestyle.py\n\n```\n\n## Todo:\n\n- [X] Create the project\n- [X] Write code and tests\n- [X] Test installation and requirements (setup.py and/or Makefile)\n- [X] Test code\n- [X] Validate features\n- [X] Write Doc/stringdoc\n- [X] Run PEP8 validation\n- [X] Clean \u0026 last check\n- [X] Release\n- [X] change (un)install process\n- [X] remove MANIFEST.in\n- [X] manage global var: __version__....\n- [X] improve the doc\n- [X] Release : 0.1.1\n- [X] improve Makefile\n- [X] Release : 0.1.2\n- [X] validate (un)install process\n- [X] rename module : pthread =\u003e pythread\n- [X] Release : 1.0.0\n- [X] fix setup\n- [X] improve docstring\n- [X] update doc\n- [X] Release : 1.1.0\n\n## License\n\nThis package is distributed under the [GPLv3 license](./LICENSE)\n### Runtime\n\n```\n\npython-3.6.x\n\n\n```\n\n### UML Diagram\n![alt text](pictures/classes_pythread.png)\n\n\n### Objects\n\n[PThread()](#pthread)\u003cbr /\u003e\n[@Property PThread.func](#property-pthreadfunc)\u003cbr /\u003e\n[PThread.start()](#pthreadstart)\u003cbr /\u003e\n[PThread.run()](#pthreadrun)\u003cbr /\u003e\n[PThread.stop()](#pthreadstop)\u003cbr /\u003e\n\n\n#### PThread()\n```python\nclass PThread(Thread):\n```\n\n```\nA class that represents a thread of control.\nThis class subclassed Thread class :\n    class Thread(builtins.object)\n\nWe specify the activity by passing a callable object to the constructor.\n\nWhy:\n    - clean the main code\n    - dedicate import Thread\n    - simplify multithreading use with generic objectives\n\nWhy we will neve use it:\n    - all the code use multithreading\n    - we use complex mecanisme between object: sync between object or\n      data issue\n\n    +----------+\n    |          |   define with func \u0026 elapse\n  --\u003e   INIT   +-------------------+----------------------+\n    |          |                   |                      |\n    +----------+                   |                      |\n                                   |                      |\n         +----------------------------------------------+ |\n         |                         |                    | |\n         |               +-----------------------------------------+\n         |               | RUN     |                    | |        |\n    +----v-----+         |    +----v-----+          +---+-v---+    |\n    |          |         |    |          |          |         |    |\n  --\u003e  START   +--------------\u003e   TASK   +----------\u003e  TIMER  |    |\n    |          |         |    |          |          |         |    |\n    +----------+         |    +----^-----+          +----^----+    |\n                         |         |                     |         |\n                         +-----------------------------------------+\n                                   |                     |\n    +----------+     disable       |                     |\n    |          +-------------------+         cancel      |\n  --\u003e   STOP   +-----------------------------------------+\n    |          +--------------------+\n    +----------+                    |\n                              +-----v-----+\n                              |           |\n                              |JOIN Thread|\n                              |           |\n                              +-----------+\n\nUse:\n    \u003e\u003e\u003e # Import the module :\n    \u003e\u003e\u003e from pythread import PThread\n    \u003e\u003e\u003e import time\n    \u003e\u003e\u003e # define a task\n    \u003e\u003e\u003e def mytask(): print(\"lorem ipsum dolor sit amet consectetur\")\n    \u003e\u003e\u003e # We want to run \"mytask\" in a thread and repeat the task:\n    \u003e\u003e\u003e mthr = PThread(mytask, 0.1)\n    \u003e\u003e\u003e mthr.start() ; print(\"other task\");time.sleep(0.3) ; mthr.stop()\n    lorem ipsum dolor sit amet consectetur\n    other task\n    lorem ipsum dolor sit amet consectetur\n    lorem ipsum dolor sit amet consectetur\n    \u003e\u003e\u003e # We want to run \"mytask\" in a thread one time:\n    \u003e\u003e\u003e mthr = PThread(mytask).start() ; print(\"other task\")\n    lorem ipsum dolor sit amet consectetur\n    other task\n    \u003e\u003e\u003e # oups - start issue:\n    \u003e\u003e\u003e mthr = PThread(mytask, 0.1)\n    \u003e\u003e\u003e mthr.start() ; mthr.start()\n    Traceback (most recent call last):\n    ...\n    RuntimeError: threads can only be started once\n    \u003e\u003e\u003e # Stop a not repeatable task:\n    \u003e\u003e\u003e mthr = PThread(mytask)\n    \u003e\u003e\u003e mthr.start() ; print(\"other task\")\n    lorem ipsum dolor sit amet consectetur\n    other task\n    \u003e\u003e\u003e mthr.stop()\n    \u003e\u003e\u003e # a test avoid the AttributeError exception\n```\n\n##### @Property PThread.func\n```python\n@property\ndef PThread.func(self):\n```\n\u003e \u003cbr /\u003e\n\u003e Returns the callable object defined by Thread constructor.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n\u003e \u003cb\u003eArgs:\u003c/b\u003e\u003cbr /\u003e\n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;  None.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n\u003e \u003cb\u003eReturns:\u003c/b\u003e\u003cbr /\u003e\n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;  callable object\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n##### PThread.start()\n```python\n\ndef PThread.start(self):\n```\n\u003e \u003cbr /\u003e\n\u003e Start the thread's activity.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n\u003e It must be called at most once per thread object. It arranges for the\u003cbr /\u003e\n\u003e object's run() method to be invoked in a separate thread of control.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n\u003e This method will raise a RuntimeError if called more than once on the\u003cbr /\u003e\n\u003e same thread object.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n\u003e \u003cb\u003eArgs:\u003c/b\u003e\u003cbr /\u003e\n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;  None.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n\u003e \u003cb\u003eReturn:\u003c/b\u003e\u003cbr /\u003e\n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;  None.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n##### PThread.run()\n```python\n\ndef PThread.run(self):\n```\n\u003e \u003cbr /\u003e\n\u003e Method (override) representing the thread's activity.\u003cbr /\u003e\n\u003e This method will raise a RuntimeError if called more than once on the\u003cbr /\u003e\n\u003e same thread object.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n\u003e \u003cb\u003eArgs:\u003c/b\u003e\u003cbr /\u003e\n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;  None.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n\u003e \u003cb\u003eReturns:\u003c/b\u003e\u003cbr /\u003e\n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;  None.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n##### PThread.stop()\n```python\n\ndef PThread.stop(self):\n```\n\u003e \u003cbr /\u003e\n\u003e Wait until the thread terminates.\u003cbr /\u003e\n\u003e This blocks the calling thread until the thread whose join() method is\u003cbr /\u003e\n\u003e called terminates -- either normally or through an unhandled exception.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n\u003e \u003cb\u003eArgs:\u003c/b\u003e\u003cbr /\u003e\n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;  None.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n\u003e \u003cb\u003eReturns:\u003c/b\u003e\u003cbr /\u003e\n\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;  None.\u003cbr /\u003e\n\u003e \u003cbr /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancois-le-ko4la%2Fpython-multithreading","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancois-le-ko4la%2Fpython-multithreading","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancois-le-ko4la%2Fpython-multithreading/lists"}