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.2.tar.gz
(14.1 kB
view hashes)
Built Distribution
Close
Hashes for hybrid_pool_executor-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f669f1bf094f1fb5c034eceb748c9c692acbfa7d25023b8c50ebf75b4c323e06 |
|
MD5 | 40dc3eee60f177c2e102c894c3c0cea0 |
|
BLAKE2b-256 | f4fdd3b047b100403c218c90f63d250d4afdfd33db2528c03d4d87cdb80fe544 |
Close
Hashes for hybrid_pool_executor-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d7c2ea3ffeaa1d2803379514962ae2c68afb367850ca219558b71f7faee0139 |
|
MD5 | cefdf73fb4049a57888bb502e8b0da01 |
|
BLAKE2b-256 | 02f94b8bd22d4bee18bce40d97d7b4d59132ce340dd2fe67322aea7fc69fa448 |