Turn a function into a process with a simple decorator.
This repo is highly inspired by python-worker
pip install python-pyprocfrom pyproc import process
@process
def func(x: int) -> int:
...
func(123)
@process
async def func(x : int) -> int:
...
await func(123)import time
@process
def func(a: int) -> int:
# do some work
time.sleep(5)
return a + 1
worker = func(10)
# this will await the worker to finished and return the value
worker.result # 11 will return after 5 seconds
worker.result # 11 no wait this timeOnly Pass Pickable Types!. Passing Non Pickable Types Like Genrators Will Cause An Error