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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for mechanicus-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4aedc57283f7317b563a45f2ac3451c42be2bb60c157bc45cdfa36382d8b82b |
|
MD5 | b77b61dfb28aab470b6d54cd53f2bf5f |
|
BLAKE2b-256 | b3850bbe8b2ed2fb11645c56c49df44ce688ac210208d8dc208aa81c31033685 |