make func async and execute in other process
Project description
process_decorator
If you write async code, you now that all code work on one processor (tnx GIL), but we can resolve this problem with execution code in other process.
ATTENTION, we get profit only if function work more than 0.1 sec or if you need make async function. AND don't work global variable, because func work in other process
from process_decorator import async_process
import asyncio
@async_process()
def test():
return 2*500000000
if __name__ == '__main__':
asyncio.run(test())
this code creates other process where will be executed.
async_process get argument exit_process_timer, witch cache process on time executed. If you call this function every time, this parameter will up speed of execution
from process_decorator import async_process
import asyncio
@async_process(exit_process_timer=10)
def test():
return 2*50000000
if __name__ == '__main__':
for _ in range(30):
asyncio.run(test())
where:
exit_process_timer - is time in second when process close if wont call
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
Built Distribution
File details
Details for the file process_decorator-0.7.1.tar.gz
.
File metadata
- Download URL: process_decorator-0.7.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67f17c5308b2142ae5539d0cded49992d0b8ba89d6e5127cac879a7483ef4939 |
|
MD5 | 78245060b1637a4cee6df50bea9135f6 |
|
BLAKE2b-256 | 0e58e86b4b98fa20f266f10f6c1dd71d8587859ce32422ad0d9b417f1c38e5cf |
File details
Details for the file process_decorator-0.7.1-py3-none-any.whl
.
File metadata
- Download URL: process_decorator-0.7.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1867edcb95a1aac310c19677a3db149a049ad97ca0b68db7d72e5ff307a0d61b |
|
MD5 | 83a26d7b4ae097b6f0cb67872b71118b |
|
BLAKE2b-256 | f9f80ca1d542963f5374fbd5531c17b94af6b36ec124bb1c9eb78fbb4760f954 |