Skip to main content

No project description provided

Project description

Mechanicus

Parallel execute with asyncio library

Install

pip3 install mechanicus

Dependencies

  • python >=3.7
  • aiohttp
  • aiofiles

Examples

Parallel file download

executor = QueueExecutor(Downloader())
await executor.execute([
    DownloadTask(
        "https://file-examples-com.github.io/uploads/2017/02/file_example_CSV_5000.csv",
        "/home/user/Downloads/example.csv",
    ),
    DownloadTask(
        "https://file-examples-com.github.io/uploads/2017/02/file_example_JSON_1kb.json",
        "/home/user/Downloads/example.json",
    )
])

Parallel custom task execute

async def source(count):
    for i in range(count):
        print(f"new: {i}")
        yield i
        await asyncio.sleep(0.2)

class CustomExecutor(TaskExecutor[int, int]):
    async def execute(self, task: int):
        print(f"start: {task}")
        await asyncio.sleep(0.5)
        print(f"complete: {task}")
        return task

executor = QueueExecutor(CustomExecutor())
result = await executor.execute(source(20))
print(f"result: {result}")

Project details


Download files

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

Source Distribution

mechanicus-0.0.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

mechanicus-0.0.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file mechanicus-0.0.2.tar.gz.

File metadata

  • Download URL: mechanicus-0.0.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.0.3 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for mechanicus-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b26b600935f45c941049f734de23e6c678e3f3089b285d54e188637a8a3b4773
MD5 c8c9ff30198d6cbe4626964a7ce01c7f
BLAKE2b-256 faf946347fc83ec4fc2468dfa274c287b441d5fa36ce326662fa92b8f0b350f0

See more details on using hashes here.

File details

Details for the file mechanicus-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: mechanicus-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.0.3 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for mechanicus-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b4aedc57283f7317b563a45f2ac3451c42be2bb60c157bc45cdfa36382d8b82b
MD5 b77b61dfb28aab470b6d54cd53f2bf5f
BLAKE2b-256 b3850bbe8b2ed2fb11645c56c49df44ce688ac210208d8dc208aa81c31033685

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page