{"id":17650812,"url":"https://github.com/whg517/aio-pydispatch","last_synced_at":"2025-05-07T07:09:10.465Z","repository":{"id":45282860,"uuid":"281355884","full_name":"whg517/aio-pydispatch","owner":"whg517","description":"asyncio pydispatch (Signal Manager)","archived":false,"fork":false,"pushed_at":"2025-01-13T17:23:53.000Z","size":76,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-25T10:52:18.863Z","etag":null,"topics":["aio-pydispatch","asyncio","asyncio-pydispatch","event","pubsub","pydispatch","signal","signal-manager"],"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/whg517.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":"2020-07-21T09:36:49.000Z","updated_at":"2023-05-06T05:50:35.000Z","dependencies_parsed_at":"2022-09-07T12:02:21.023Z","dependency_job_id":null,"html_url":"https://github.com/whg517/aio-pydispatch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whg517%2Faio-pydispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whg517%2Faio-pydispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whg517%2Faio-pydispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whg517%2Faio-pydispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whg517","download_url":"https://codeload.github.com/whg517/aio-pydispatch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242930128,"owners_count":20208406,"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":["aio-pydispatch","asyncio","asyncio-pydispatch","event","pubsub","pydispatch","signal","signal-manager"],"created_at":"2024-10-23T11:39:30.424Z","updated_at":"2025-03-10T21:31:01.721Z","avatar_url":"https://github.com/whg517.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aio_pydispatch\n\n![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/whg517/aio-pydispatch/main/main?style=flat-square)\n![GitHub](https://img.shields.io/github/license/whg517/aio-pydispatch?style=flat-square)\n![PyPI](https://img.shields.io/pypi/v/aio_pydispatch?style=flat-square)\n[![codecov](https://codecov.io/gh/whg517/aio-pydispatch/branch/main/graph/badge.svg?token=YF339UJGAD)](https://codecov.io/gh/whg517/aio-pydispatch)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ccb3b0e652e04496872f2477af5078eb)](https://www.codacy.com/gh/whg517/aio-pydispatch/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=whg517/aio-pydispatch\u0026amp;utm_campaign=Badge_Grade)\n\nAsyncio pydispatch (Signal Manager)\n\nThis is based on [pyDispatcher](http://pydispatcher.sourceforge.net/) reference\n[Django Signals](https://docs.djangoproject.com/en/4.0/topics/signals/) and reference\n[scrapy SignalManager](https://docs.scrapy.org/en/latest/topics/signals.html) implementation on\n[Asyncio](https://docs.python.org/3/library/asyncio.html)\n\n## Event or Signal (not python bif signal)\n\nYou can bind multiple listeners (called sender) to listening multiple handlers (called receiver)\non one event (called signal). \n\nDefault, the listener is None, so when the event is fire with no listener, all handlers will be \nexecuted that was bind default listener.\n\n## Usage\n\nMost of the program has `start` and `stop` events, we can register some handler to events,\nwe can also specify a sender.\n\n```python\nimport asyncio\n\nfrom aio_pydispatch import Signal\n\nserver_start = Signal()\nserver_stop = Signal()\n\n\ndef ppp(value: str, **kwargs) -\u003e None:\n    print(value, kwargs)\n\n\nasync def main():\n    server_start.connect(ppp, sender='loading config')\n    server_stop.connect(ppp)\n    await server_start.send(sender='loading config', value='foo')\n    await asyncio.sleep(1)\n    await server_stop.send(value='foo')\n\n\nif __name__ == '__main__':\n    asyncio.run(main())\n\n```\n\n## Similar design\n\nsync:\n\n- [pyDispatcher](http://pydispatcher.sourceforge.net/)\n- [Django.dispatch](https://github.com/django/django/tree/master/django/dispatch)\n- [scrapy SignalManager](https://docs.scrapy.org/en/latest/topics/signals.html)\n- [blinker](https://pythonhosted.org/blinker/)\n\nasync:\n\n- [Aiohttp tracing](https://github.com/aio-libs/aiohttp/blob/master/aiohttp/tracing.py)\n\n## Others\n\n[Event system in Python](https://stackoverflow.com/a/16192256/11722440)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhg517%2Faio-pydispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhg517%2Faio-pydispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhg517%2Faio-pydispatch/lists"}