asyncio-executor
version: 0.0.4
status: dev
author: hsz
email: hsz1273327@gmail.com
Desc
Asyncio executor for running coroutines. This code is from <https://gist.github.com/seglberg/0b4487b57b4fd425c56ad72aba9971be>
keywords:asyncio,executor
Feature
run coroutines asynchronously
Example
run coroutines by using submit
from concurrent.futures import as_completed
import aiohttp
from asyncio_executor import AsyncioExecutor
async def httpget(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
html = await resp.text("utf-8")
return len(html)
with AsyncioExecutor() as executor:
to_do = []
urls = ["https://github.com/","https://docs.aiohttp.org/"]
for i in urls:
job = executor.submit(httpget,i)
to_do.append(job)
for future in as_completed(to_do):
res = future.result()
run coroutines by using map
from concurrent.futures import as_completed
import aiohttp
from asyncio_executor import AsyncioExecutor
async def httpget(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
html = await resp.text("utf-8")
return len(html)
with AsyncioExecutor() as executor:
result = []
urls = ["https://github.com/", "https://docs.aiohttp.org/"]
for i in executor.map(httpget, urls):
result.append(i)
run functions by using submit
from concurrent.futures import as_completed
import requests as rq
from asyncio_executor import AsyncioExecutor
def httpsync(url):
req = rq.get(url)
return len(req.text)
with AsyncioExecutor() as executor:
to_do = []
urls = ["https://github.com/", "https://docs.aiohttp.org/"]
for i in urls:
job = executor.submit(httpsync, i)
to_do.append(job)
for future in as_completed(to_do):
res = future.result()
print(res)
run functions by using map
from concurrent.futures import as_completed
import requests as rq
from asyncio_executor import AsyncioExecutor
def httpsync(url):
req = rq.get(url)
return len(req.text)
with AsyncioExecutor() as executor:
result = []
urls = ["https://github.com/", "https://docs.aiohttp.org/"]
for i in executor.map(httpsync, urls):
result.append(i)
print(result)
Install
python -m pip install asyncio-executor
Limitations
only support python 3.5+
Metadata
Release files for asyncio-executor 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asyncio-executor-0.0.4.tar.gz | 5.4 kB | Without provenance | Details for asyncio-executor-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asyncio_executor-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for asyncio_executor-0.0.4-py3-none-any.whl |
Total release size: 12.1 kB
Release files / asyncio-executor-0.0.4.tar.gz
| Download URL | asyncio-executor-0.0.4.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0aa050596f51d653a18bdc7a7347b4471607bd098948630eb27190fe2931b38
|
|
BLAKE2b-256 checksum How to use checksums |
822a66a186e00d27e5d36a5c1f308619169f9659b1957d89f6a9f2146dfc68f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Release files / asyncio_executor-0.0.4-py3-none-any.whl
| Download URL | asyncio_executor-0.0.4-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
893db7b027172450256d3336833101a873269abc889aba819b761a0d4ab8cbb0
|
|
BLAKE2b-256 checksum How to use checksums |
af34c8d2a3dea646fc6b4f764d4cb46f69a9992e3cd501ce26d4ce3137937ccb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Security for asyncio-executor 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.