Home > other >  Process variable assignment problem
Process variable assignment problem

Time:05-11

The from multiprocessing import Process
The class TestProcess (Process) :
Def __init__ (self) - & gt; None:
Super (TestProcess, self) __init__ ()
Print (" __init__ ")
The self. The __name=None

Def run (self) :
If self. __name is None:
Print (" init self name ")
The self. The __name="test"
Print (self. __name)
Def the run () :
T=TestProcess ()

T.s tart ()
T.j oin ()


# the second
T.r UN ()
T.j oin ()

T.r UN ()
T.j oin ()

T.r UN ()
T.j oin ()

T.r UN ()
T.j oin ()


If __name__=="__main__ ':
The run ()


Why the second run, the self. The __name to None
  • Related