{"id":22301160,"url":"https://github.com/chamilad/breadpool","last_synced_at":"2026-01-12T14:02:33.860Z","repository":{"id":57416317,"uuid":"47139867","full_name":"chamilad/breadpool","owner":"chamilad","description":"A Python Thread Pool ","archived":false,"fork":false,"pushed_at":"2019-11-25T23:59:12.000Z","size":39,"stargazers_count":3,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-30T22:51:40.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chamilad.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}},"created_at":"2015-11-30T19:06:43.000Z","updated_at":"2021-07-08T17:55:39.000Z","dependencies_parsed_at":"2022-09-05T04:42:21.787Z","dependency_job_id":null,"html_url":"https://github.com/chamilad/breadpool","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/chamilad/breadpool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamilad%2Fbreadpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamilad%2Fbreadpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamilad%2Fbreadpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamilad%2Fbreadpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chamilad","download_url":"https://codeload.github.com/chamilad/breadpool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamilad%2Fbreadpool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28340224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-12-03T18:17:48.318Z","updated_at":"2026-01-12T14:02:33.838Z","avatar_url":"https://github.com/chamilad.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/chamilad/breadpool.svg?branch=master)](https://travis-ci.org/chamilad/breadpool) \n[![Coverage Status](https://coveralls.io/repos/chamilad/breadpool/badge.svg?branch=master\u0026service=github?dd=gg)](https://coveralls.io/github/chamilad/breadpool?branch=master)\n[![Documentation Status](https://readthedocs.org/projects/breadpool/badge/?version=latest)](http://breadpool.readthedocs.org/en/latest/?badge=latest)\n[![PyPI version](https://badge.fury.io/py/breadpool.svg)](https://badge.fury.io/py/breadpool)\n\n# BreadPool \n##A Python Thread Pool and a Scheduled Executor\n\nBreadPool intends to simply provide implementations for a thread pool and a scheduled executor, with\neasy to use interfaces and thread safety. Yes, it is a simple code to write your own implementations\nfor these, however it can be a lot easier if they come in a `pip install`.\n\n## Installing BreadPool\nBreadPool can be installed from the Python Package Index.\n\n```bash\npip install breadpool\n```\n\n## ThreadPool\nThe `ThreadPool` class is a simple thread pool implementation. It will initially create a set of worker threads and when assigned tasks, the worker threads will take over and execute the tasks.\n\n### Creating a ThreadPool\n\n```python\nfrom breadpool.pool import ThreadPool\n\n\"\"\"\n1 - number of threads to spawn\n2 - An identifying name to be assigned to the threads\n3 - daemon, True if you want the threads to immediately terminate when the main thread terminates. This is set to False by default\n4 - polling_timeout is the timeout for the worker threads to blockingly wait for the task queue\n\"\"\"\nthread_pool = ThreadPool(5, \"CustomThreadPool\", polling_timeout=1)\n\n```\n\n### Enqueuing tasks\nThe tasks should be implemented by extending the `AbstractRunnable` class. BreadPool provides a simple implementation of the `AbstractRunnable` class called `EasyTask` which accepts a function as the task to be executed.\n\n```python\nfrom breadpool.pool import ThreadPool, EasyTask\n\ndef func_test():\n    time.sleep(random.randint(1, 5))\net = EasyTask(func_test)\nthread_pool = ThreadPool(5, \"CustomThreadPool\", daemon=True)\nthread_pool.enqueue(et)\n```\n\n### Extending `AbstractRunnable`\nOr if your task is too complex for a simple function, you can extend the `AbstractRunnable` class and write your own task implementation.\n\n```python\nfrom breadpool.pool import AbstractRunnable\n\nclass CustomTask(AbstractRunnable):\n    def execute(self):\n        # task steps\n\n    def __init__(self):\n        # task initialization\n\n```\n\n## ScheduledJobExecutor\nThis is a simple scheduled executor for tasks of type `AbstractRunnable`. It will periodically and repeatedly execute the given task with at least the given time interval.\n\n### Usage\n\n```python\nfrom breadpool.pool import ThreadPool, ScheduledJobExecutor, EasyTask\n\nthread_pool = ThreadPool(3, \"CustomThreadPool\", polling_timeout=20)\ncounter_queue = Queue()\nscheduled_executor = ScheduledJobExecutor(\n    EasyTask(lambda(l): counter_queue.put(l), \"Test %s\" % time.time()),\n    thread_pool,\n    5,\n    \"CustomScheduledExecutor\")\n\nscheduled_executor.start()\n....\nscheduled_executor.terminate()\n```\n\n## Python Support\nBreadPool supports only Python 2.7 (for now).\n\n## License\nBreadPool is an Apache v2.0 licensed project. \n\n## Additional Links\n\n1. ReadTheDocs - http://breadpool.readthedocs.org/en/latest/\n2. PyPI - https://pypi.python.org/pypi/breadpool\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchamilad%2Fbreadpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchamilad%2Fbreadpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchamilad%2Fbreadpool/lists"}