PyDocs

Nav

Concurrent Execution

Process

multiprocessing

class (source) not Androidnot iOSnot WASI
  • Process(group=None, target=None, name=None, args=(), kwargs={}, *, daemon=None)
Process objects represent activity that is run in a separate process. The Process class has equivalents of all the methods of threading.Thread.
Changed in 3.3
  • 3.3: Added the daemon parameter.
Members of Process

a

authkey
The process’s authentication key (a byte string).

c

close
Close the Process object.

d

daemon
Return whether process is a daemon

e

exitcode
Return exit code of process or `None` if it has yet to stop

i

interrupt
Terminate process; sends SIGINT signal
is_alive
Return whether process is alive

j

join
Wait until child process terminates

k

kill
Terminate process; sends SIGKILL signal or uses TerminateProcess()

n

name
The process’s name.

p

pid
Return identifier (PID) of process or `None` if it has yet to start

r

run
Method to be run in sub-process; can be overridden in sub-class

s

sentinel
Return a file descriptor (Unix) or handle (Windows) suitable for waiting for process termination.
start
Start child process

t

terminate
Terminate process; sends SIGTERM signal or uses TerminateProcess()
1 Example
>>> import multiprocessing as mp
>>> def knigit():
...     print("Ni!")
...
>>> process = mp.Process(target=knigit)
>>> process.start()
>>> Traceback (most recent call last):
  File ".../multiprocessing/spawn.py", line ..., in spawn_main
  File ".../multiprocessing/spawn.py", line ..., in _main
AttributeError: module '__main__' has no attribute 'knigit'
>>> process
<SpawnProcess name='SpawnProcess-1' pid=379473 parent=378707 stopped exitcode=1>
from the Python docs
See Also
No see-alsos for multiprocessing/Process
0 Notes
No notes for Process