async4s - 一个简单易用的异步执行模块
About
这是一个简单易用的异步执行模块,可以使原有方法轻松变为异步执行。
Requirements
- Python3
Install
通过pip命令安装:
pip install async4s
Example
- async by thread
import time
from async4s.mw.thread import Master, Worker
def work(i):
time.sleep(i)
return i
def callback(results):
print(results)
print(time.perf_counter())
workers = [Worker(work, i) for i in range(5)]
m = Master(workers, callback)
print("main")
m.wait()
print(time.perf_counter())
- async by asyncio
import time
import asyncio
from async4s.mw.coroutine import Master, Worker
async def work(i):
await asyncio.sleep(i)
return i
def callback(results):
print(results)
print(time.perf_counter())
workders = (Worker(work, i) for i in range(5))
master = Master(workders, callback=callback)
print("main")
master.wait()
print(time.perf_counter())
Release History
0.0.1(2021-01-26)
- Birth
1.0.0(2021-10-29)
- Master-Worker mode
- both implement by thread and asyncio
Author
Metadata
Release files for async4s 2.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| async4s-2.4.0.zip | 14.3 kB | Details |
Release files / async4s-2.4.0.zip
| Download URL | async4s-2.4.0.zip |
|---|---|
| Size | 14.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab0aa3cb5f76dc85c6b5506c5f0968ae91292cc20d35456cfb11ccd5d879ce06
|
|
BLAKE2b-256 checksum How to use checksums |
d53f51835d507d79175b96bf5176bfd279019231597f794766f605920ac719f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.5
|