{"id":41701556,"url":"https://github.com/sric0880/pyrpcindaemon","last_synced_at":"2026-01-24T21:00:13.851Z","repository":{"id":255474332,"uuid":"850980963","full_name":"sric0880/pyRPCInDaemon","owner":"sric0880","description":"run and shutdown a python module in daemon or in frontground using ssh(available on linux and windows) 使用ssh远程运行或关闭python模块，后台运行。[Linux 和 Windows通用]","archived":false,"fork":false,"pushed_at":"2024-09-09T09:04:25.000Z","size":124,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-09T10:54:14.774Z","etag":null,"topics":["daemon","daemoniker","daemonize","paramiko","remote-python-execution","rpc","ssh"],"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/sric0880.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":"2024-09-02T07:50:07.000Z","updated_at":"2024-09-09T09:04:29.000Z","dependencies_parsed_at":"2024-09-09T10:36:31.638Z","dependency_job_id":null,"html_url":"https://github.com/sric0880/pyRPCInDaemon","commit_stats":null,"previous_names":["sric0880/pyrpcindaemon"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sric0880/pyRPCInDaemon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sric0880%2FpyRPCInDaemon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sric0880%2FpyRPCInDaemon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sric0880%2FpyRPCInDaemon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sric0880%2FpyRPCInDaemon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sric0880","download_url":"https://codeload.github.com/sric0880/pyRPCInDaemon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sric0880%2FpyRPCInDaemon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28736798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T19:23:36.361Z","status":"ssl_error","status_checked_at":"2026-01-24T19:23:28.966Z","response_time":89,"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":["daemon","daemoniker","daemonize","paramiko","remote-python-execution","rpc","ssh"],"created_at":"2026-01-24T21:00:12.999Z","updated_at":"2026-01-24T21:00:13.811Z","avatar_url":"https://github.com/sric0880.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyRPCInDaemon\n\n## Install\n\n```sh\npip install .\n```\n\n## Usage\n\nThese are more use cases in tests folder.\n\n### TCP server based task\n\n```python\nimport rpcindaemon\n\ntask_id = 1000\ncmd = \"python heavy_task.py --arg-live-time=40\"\nport = 9999 # optional\nt = rpcindaemon.Task(\n    task_id,\n    cmd,\n    ssh_config[\"hostname\"],\n    username=ssh_config[\"user\"],\n    password=ssh_config[\"pwd\"],\n    port=port,\n)\n```\n\nin `heavy_task.py`\n\n```python\nimport fire\nimport rpcindaemon\n\nclass CustomServerCmd(rpcindaemon.ServerCmd):\n    def add(self, arg1, arg2=1):\n        return arg1 + arg2\n\n@rpcindaemon.makedaemon(server_cmd=CustomServerCmd)\ndef heavy_backgournd_task(task_id: int, f: rpcindaemon.F, arg_live_time=20):\n    t = 0\n    while True:\n        if t \u003e arg_live_time:\n            break\n        time.sleep(0.5)\n        t += 0.5\n\nif __name__ == \"__main__\":\n    fire.Fire(heavy_backgournd_task)\n```\n\nthen you can send do `add` from remote task\n\n```python\nassert t.do_rpc(\"add\", 1, 2) == 3\nassert t.do_rpc(\"add\", 1) == 2\n```\n\nor you can generate multiple processes in daemon task\n\n```python\nimport time\nimport rpcindaemon\nimport multiprocessing\n\ndef child_process(a, is_daemon):\n    msg_queue = rpcindaemon.daemonize.message_queue\n    lock = rpcindaemon.daemonize.lock\n    with lock:\n        msg_queue.put(f\"{a}: send message to parent process\")\n        time.sleep(1)\n\n@rpcindaemon.makedaemon()\ndef heavy_multiprocess_task(task_id: int, f: rpcindaemon.F, max_cpus=None):\n    def msg_handler(msg):\n        print(msg)\n    args = list(range(20))\n    f.run_parallel(\n        child_process,\n        args,\n        max_cpus=max_cpus,\n        lock=multiprocessing.Lock(),\n        message_queue=multiprocessing.JoinableQueue(),\n        message_handler=msg_handler,\n    )\n\nif __name__ == \"__main__\":\n    fire.Fire(heavy_multiprocess_task)\n```\n\nyou can terminate remote daemon task(process) whenever you want. you can setup your own signal handlers for quiting gracefully.\n\n```python\nt.terminate()\n```\n\n## Third-party library\n\n- [daemoniker](https://pypi.org/project/daemoniker) with a little modification of the source code\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsric0880%2Fpyrpcindaemon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsric0880%2Fpyrpcindaemon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsric0880%2Fpyrpcindaemon/lists"}