{"id":26121708,"url":"https://github.com/threezh1/pythonasync","last_synced_at":"2025-04-13T13:04:09.654Z","repository":{"id":119030431,"uuid":"259913687","full_name":"Threezh1/PythonAsync","owner":"Threezh1","description":"Python 协程的利用框架，可以自主设置调用的函数以及线程。方便大家编写需要用到协程的Python脚本。","archived":false,"fork":false,"pushed_at":"2020-04-29T12:09:21.000Z","size":11,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-13T13:03:57.836Z","etag":null,"topics":["async","asyncio","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Threezh1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-04-29T12:02:15.000Z","updated_at":"2020-08-28T08:45:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"b2ced800-afaa-4b70-a2de-c73ee2fa4f60","html_url":"https://github.com/Threezh1/PythonAsync","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Threezh1%2FPythonAsync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Threezh1%2FPythonAsync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Threezh1%2FPythonAsync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Threezh1%2FPythonAsync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Threezh1","download_url":"https://codeload.github.com/Threezh1/PythonAsync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717247,"owners_count":21150389,"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","asyncio","python"],"created_at":"2025-03-10T14:35:35.987Z","updated_at":"2025-04-13T13:04:09.649Z","avatar_url":"https://github.com/Threezh1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PythonAsync\n\nPython 协程的利用框架，可以自主设置调用的函数以及线程。方便大家编写需要用到协程的Python脚本。\n\n博客文章：[协程初体验之简单的利用框架](https://threezh1.com/2019/08/22/%E7%AE%80%E5%8D%95%E7%9A%84%E5%8D%8F%E7%A8%8B%E5%88%A9%E7%94%A8%E6%A1%86%E6%9E%B6/)\n\n框架运行的结果为：\n\n```\nI'm Threezh1.\nHello World.\nWelcome to my blog.\n[*] The 1th thread ends\nOne\nThree\nTow\n[*] The 2th thread ends\nFour\n[*] The 3th thread ends\n[Finished in 3.2s]\n```\n\n一共只花费3秒\n\n## 框架的使用\n\n- SomeFunction() \t\t需要实现并发的函数\n- coroutine_execution() 新建一个线程来执行并发函数\n- coroutine_init()\t\t处理线程与调配任务\n\n流程图：\n\n![process.png](https://i.loli.net/2019/08/22/1fUmqKRNigF89DV.png)\n\n需要调整的内容：\n\n一. 传递的参数列表\n\t\n\t列表中单个成员最后都会被赋值到目标函数。\n\t比如：批量获取网站标题，这里的成员就为单个url。\n\n二. 目标函数的参数\n\n\t通过调整目标函数的参数个数，可以使框架适用于更加复杂的场景。\n\t需要注意的是各个函数互相调用，其中的参数要尽量保持一致。\n\n三. 返回结果的获取\n\n\t在单个线程当中无法对全局变量进行修改，对结果的处理可以放在coroutine_execution()当中。\n\tcoroutine_execution()中也可以直接return结果，则会返回到coroutine_init()中。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreezh1%2Fpythonasync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreezh1%2Fpythonasync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreezh1%2Fpythonasync/lists"}