{"id":37733714,"url":"https://github.com/dzhsurf/pynoticenter","last_synced_at":"2026-01-16T13:54:54.828Z","repository":{"id":58543580,"uuid":"532183023","full_name":"dzhsurf/pynoticenter","owner":"dzhsurf","description":"Python client side notification center.","archived":false,"fork":false,"pushed_at":"2022-10-18T17:54:58.000Z","size":325,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-25T08:19:56.484Z","etag":null,"topics":["multithread-taskqueue","notificationcenter","taskqueue"],"latest_commit_sha":null,"homepage":"","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/dzhsurf.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":"2022-09-03T06:59:57.000Z","updated_at":"2022-09-29T18:01:35.000Z","dependencies_parsed_at":"2022-09-04T21:25:19.843Z","dependency_job_id":null,"html_url":"https://github.com/dzhsurf/pynoticenter","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/dzhsurf/pynoticenter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzhsurf%2Fpynoticenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzhsurf%2Fpynoticenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzhsurf%2Fpynoticenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzhsurf%2Fpynoticenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dzhsurf","download_url":"https://codeload.github.com/dzhsurf/pynoticenter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzhsurf%2Fpynoticenter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: 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":["multithread-taskqueue","notificationcenter","taskqueue"],"created_at":"2026-01-16T13:54:54.772Z","updated_at":"2026-01-16T13:54:54.822Z","avatar_url":"https://github.com/dzhsurf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Quickstart\n==========\n\n[![Docs](https://img.shields.io/badge/docs-latest-informational)](https://dzhsurf.github.io/pynoticenter/)\n\nPyPI: [https://pypi.org/project/pynoticenter/](https://pypi.org/project/pynoticenter/)\n\nIntroduction\n------------\n\nPyNotiCenter is a multithreaded task queue and message notification center. It mainly provides in-process lightweight task scheduling management for client applications, that why we choose the multi-threaded mode. Although the multi-threaded mode is not a good practice most of the time in Python(In CPU-bound tasks it can't be genuinely parallel as the GIL exists). But in developing client applications, it will be one of the most important base components.\n\nAs it is based on a multi-threaded mode, multi-threaded development must pay attention to thread safety issues, which is inevitable. In order to reduce the complexity for developers, all interfaces of this library are thread safety. It is designed to be called in any thread to guarantee the same results as expected, even though this will cause some performance issues.\n\nThe library mainly provides 2 features.\n\n* Task queue: each task queue will run in a separate thread.\n* Message notification: the message notification scheduling is based on the built-in task queue.\n\nInstall\n-------\n\n```shell\npip install pynoticenter\n```\n\nCode Example\n------------\n\n* Post task to task queue.\n\n```python\ndef fn(*args: Any, **kwargs: Any):\n    print(*args)\n\ndef main():\n    PyNotiCenter.default().post_task(fn, \"hello world\")\n    PyNotiCenter.default().post_task_with_delay(5, False, fn, \"hello\", \"world\", \"delay 5s\")\n    PyNotiCenter.default().shutdown(wait=True)\n```\n\n```shell\n[2022-09-03 20:54:23,698] {task_queue.py:177} INFO - TaskQueue[4408264928]: worker thread begin.\n[2022-09-03 20:54:23,699] {task_queue.py:46} INFO - TaskQueue[4408264928]: Task queue terminate. wait: True\n[2022-09-03 20:54:23,699] {task_queue.py:105} INFO - TaskQueue[4408264928]: waiting for tasks cleanup. tasks: 2\nhello world\nhello world delay 5s\n[2022-09-03 20:54:28,721] {task_queue.py:114} INFO - TaskQueue[4408264928]: All tasks cleanup. wait time: 5.0\n[2022-09-03 20:54:28,722] {task_queue.py:117} INFO - TaskQueue[4408264928]: waiting for thread exit.\n[2022-09-03 20:54:28,722] {task_queue.py:137} INFO - TaskQueue[4408264928]: stop event run loop.\n[2022-09-03 20:54:28,723] {task_queue.py:200} INFO - TaskQueue[4408264928]: worker thread end.\n[2022-09-03 20:54:29,726] {task_queue.py:126} INFO - TaskQueue[4408264928]: thread exit. wait time: 1.0\n```\n\n```python\n# async func\nasync def async_fn(msg: str):\n  await asyncio.sleep(1)\n  print(f\"msg: {msg}\")\n\ndef fn(msg: str):\n  print(f\"msg: {msg}\")\n\ndef main():\n  PyNotiCenter.default().post_task(fn, \"hello\")\n  PyNotiCenter.default().post_task(async_fn, \"hello\")\n  PyNotiCenter.default().wait_until_task_complete()\n  PyNotiCenter.default().shutdown(wait=True)\n```\n\n* Notification\n\n```python\nclass A:\n    def say_hello(self, who: str):\n        print(f\"{who}: hello\")\n\ndef main():\n    receiver = A()\n    PyNotiCenter.default().add_observer(\"say_hello\", receiver.say_hello, receiver)\n    PyNotiCenter.default().notify_observers(\"say_hello\", \"baby\")\n    ...\n    PyNotiCenter.default().remove_observers(receiver)\n    PyNotiCenter.default().shutdown(wait=True)\n```\n\n* Notification on specific thread, such as Gtk main thread.\n\n```python\ndef fn():\n    pass\n\ndef switch_to_gtk_thread(fn: Callable, *args: Any, **kwargs) -\u003e bool:\n    GLib.idle_add(fn)\n    return True\n\ndef main():\n    queue = PyNotiCenter.default().create_task_queue(PyNotiOptions(queue='mytask'))\n    queue.set_preprocessor(switch_to_gtk_thread)\n    queue.post_task(fn) # fn run in gtk thread\n\n    # notification run on mytask queue.\n    PyNotiCenter.default().add_observer(\"say_hello\", fn, options=PyNotiOptions(queue=\"mytask\"))\n    PyNotiCenter.default().notify_observers(\"say_hello\")\n```\n\nPost task with task id\n\n```python\ndef fn_with_task_id(task_id: str, msg: str):\n    pass\n\ndef main():\n    queue = PyNotiCenter.default().create_task_queue(PyNotiOptions(queue='mytask', fn_with_task_id=True))\n    task_id = queue.post_task(fn_with_task_id, 'Hi')\n    queue.cancel_task(task_id)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzhsurf%2Fpynoticenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdzhsurf%2Fpynoticenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzhsurf%2Fpynoticenter/lists"}