Skip to main content

async4s - 一个简单易用的异步执行模块

image image image

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async4s-2.0.1.zip (12.1 kB view details)

Uploaded Source

File details

Details for the file async4s-2.0.1.zip.

File metadata

  • Download URL: async4s-2.0.1.zip
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.26.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for async4s-2.0.1.zip
Algorithm Hash digest
SHA256 569139a5f2b16b8064df1165eabcaa2ea3a1f650560f2326a94b381aa5e18d39
MD5 f61f129b0f65c1e301ea879697bdc14e
BLAKE2b-256 e35b377c383754008c90d4478773c72f751b587f35fcbf408eff6e60aff9de8b

See more details on using hashes here.

Release history Release notifications | RSS feed

2.4.0

1 file

2.3.2

1 file

2.3.1

1 file

2.3.0

1 file

2.1.0

1 file

This release

2.0.1 This release

1 file

2.0.0

1 file

1.0.0

1 file

0.0.3

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page