Pool executor supporting thread, process and async.
Project description
HybridPoolExecutor is a parallel executor that supports thead, process and async three operating models at the same time.
Example:
import asyncio
import time
import random
from hybrid_pool_executor import HybridPoolExecutor
def func1():
print('func1 starts')
time.sleep(random.randint(1, 4))
print('func1 ends')
return 1
def func2():
print('func2 starts')
time.sleep(random.randint(1, 4))
print('func2 ends')
return 2
async def func3():
print('func3 starts')
await asyncio.sleep(random.randint(1, 4))
print('func3 ends')
return 3
def test_run():
pool = HybridPoolExecutor()
future1 = pool.submit(func1) # run in a thread
future2 = pool.submit(func2, mode='process') # run in a process
future3 = pool.submit(func3) # run as a coroutine
if __name__ == '__main__':
test_run()
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
hybrid_pool_executor-0.0.1.tar.gz
(11.5 kB
view hashes)
Built Distribution
Close
Hashes for hybrid_pool_executor-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80254898376bbe33e5147a7799708c8222f7d6a393e168d11e0792250ae0d285 |
|
MD5 | 165f80a8ea4aed075cf1e5ab6e26b1f0 |
|
BLAKE2b-256 | ab5e82cd45316e83a5e2e6975844378abacea83da575345579bc8395110820ff |
Close
Hashes for hybrid_pool_executor-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6360cc2cb110127706f32695f0c3783f21ec9015bfab36d0d73adc8537306b1 |
|
MD5 | 972f540d11d199367473b9574ce3bc59 |
|
BLAKE2b-256 | b50f3a67c15e2678328830068217731de64cc8791b3d4d7016df8031d54b67db |