{"id":22887636,"url":"https://github.com/dedinc/pythread","last_synced_at":"2025-05-07T11:21:41.283Z","repository":{"id":57457784,"uuid":"359432685","full_name":"DedInc/pythread","owner":"DedInc","description":"A Python library providing a user-friendly interface for managing both synchronous and asynchronous threads.","archived":false,"fork":false,"pushed_at":"2024-01-11T06:00:01.000Z","size":5,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T16:48:23.560Z","etag":null,"topics":["async-manager","asyncio","manager","pythread","task-manager","thread","thread-management","thread-manager","threading"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pythread","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DedInc.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":"2021-04-19T11:21:17.000Z","updated_at":"2024-01-11T05:54:07.000Z","dependencies_parsed_at":"2024-12-13T20:37:39.916Z","dependency_job_id":"2688858c-112f-462b-b943-bb15f52d30e2","html_url":"https://github.com/DedInc/pythread","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"005edccbbb5fe82427df5a4799f220f1a48243fa"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DedInc%2Fpythread","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DedInc%2Fpythread/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DedInc%2Fpythread/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DedInc%2Fpythread/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DedInc","download_url":"https://codeload.github.com/DedInc/pythread/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252866123,"owners_count":21816397,"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","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":["async-manager","asyncio","manager","pythread","task-manager","thread","thread-management","thread-manager","threading"],"created_at":"2024-12-13T20:37:30.400Z","updated_at":"2025-05-07T11:21:41.271Z","avatar_url":"https://github.com/DedInc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pythread 🧵\n\nA Python library providing a user-friendly interface for managing both synchronous and asynchronous threads.\n\n## Description 📚\n\n**pythread** is a dual-threading Python library crafted to streamline the creation and management of threads in Python applications. It offers two distinct managers: \n\n- **SyncThreadManager**: Handles classic synchronous threads for executing blocking operations.\n- **AsyncThreadManager**: Manages asynchronous tasks to run coroutines in a non-blocking fashion.\n\nWith **pythread**, starting, stopping, and supervising the life cycle of threads and async tasks becomes effortless, enhancing the readability and resilience of your code.\n\n## Features ✨\n\n- Initiate and terminate threads/tasks by name or reference.\n- Accommodates additional arguments for threads/tasks.\n- Simple management of thread/task lifecycle.\n- Suitable for both sync and async implementations.\n\n## Installation 📥\n\nTo get started with **pythread**, run:\n\n```sh\npip install pythread\n```\n\n## Use Cases 🔧\n\n- Conducting background tasks like I/O operations, processing data, or scheduled tasks.\n- Handling multiple network connections in parallel.\n- Implementing producer-consumer patterns using thread-safe queues.\n- Crafting a basic task scheduler for time-based task execution.\n\n## Documentation 📄\n\n### SyncThreadManager\n\nFacilitates the creation of synchronous threads for running functions with specific delays.\n\n```python\n# Initialize the SyncThreadManager\nmanager = SyncThreadManager()\n\n# Function to run in a separate thread\ndef print_message(message):\n    print(f\"Thread message: {message}\")\n\n# Start a new thread with a specific action and delay\nthread = manager.start_thread(name='PrinterThread', func=print_message, delay=1, \n    message='Hello from SyncThread!'\n)\n\n# Stop the thread using its name\nmanager.stop_thread('PrinterThread')\n\n# Stop the thread using the thread object\nmanager.stop_thread(thread)\n```\n\n### AsyncThreadManager\n\nEnables the execution of async coroutines concurrently.\n\n```python\nimport asyncio\nfrom pythread import AsyncThreadManager\n\n# Initialize the AsyncThreadManager\nmanager = AsyncThreadManager()\n\n# Example coroutine function\nasync def async_print_message(message):\n    print(f\"Async message: {message}\")\n\n# Start and run an async task\nloop = asyncio.get_event_loop()\ntask = loop.run_until_complete(manager.start_task(name='AsyncPrinter', coro_func=async_print_message, message='Hello from AsyncThread!'))\n\n# Stop the task using its name\nloop.run_until_complete(manager.stop_task('AsyncPrinter'))\n\n# Stop the task using the task object\nloop.run_until_complete(manager.stop_task(task))\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdedinc%2Fpythread","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdedinc%2Fpythread","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdedinc%2Fpythread/lists"}