Add async fork
Change-Id: Ib81697fbef0ed1fc803a36c7489b998cba63cfba
This commit is contained in:
parent
eb95774f43
commit
b228e9ccdb
|
@ -2,4 +2,5 @@
|
|||
*.pyc
|
||||
dist/
|
||||
*.egg-info/
|
||||
*.egg/
|
||||
build/
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
import threading
|
||||
from rackclient import process_context
|
||||
from rackclient.v1.syscall.default import pipe as rackpipe, file as rackfile
|
||||
|
||||
PCTXT = process_context.PCTXT
|
||||
|
||||
|
||||
def fork(pid=PCTXT.pid, **kwargs):
|
||||
def fork(pid=PCTXT.pid, is_async=False, **kwargs):
|
||||
if is_async:
|
||||
th = threading.Thread(target=_fork, args=[pid], kwargs=kwargs)
|
||||
th.start()
|
||||
return th
|
||||
else:
|
||||
return _fork(pid, **kwargs)
|
||||
|
||||
|
||||
def _fork(pid, **kwargs):
|
||||
child = PCTXT.client.processes.create(gid=PCTXT.gid, ppid=pid, **kwargs)
|
||||
rackpipe.Pipe.share(pid, child.pid)
|
||||
return child
|
||||
|
|
Loading…
Reference in New Issue