MCPcopy Index your code
hub / github.com/RustPython/RustPython / __init__

Method __init__

Lib/test/_test_multiprocessing.py:1983–2009  ·  view source on GitHub ↗

Construct a bunch of `n` threads running the same function `f`. If `wait_before_exit` is True, the threads won't terminate until do_finish() is called.

(self, namespace, f, args, n, wait_before_exit=False)

Source from the content-addressed store, hash-verified

1981 A bunch of threads.
1982 """
1983 def __init__(self, namespace, f, args, n, wait_before_exit=False):
1984 """
1985 Construct a bunch of `n` threads running the same function `f`.
1986 If `wait_before_exit` is True, the threads won't terminate until
1987 do_finish() is called.
1988 """
1989 self.f = f
1990 self.args = args
1991 self.n = n
1992 self.started = namespace.DummyList()
1993 self.finished = namespace.DummyList()
1994 self._can_exit = namespace.Event()
1995 if not wait_before_exit:
1996 self._can_exit.set()
1997
1998 threads = []
1999 for i in range(n):
2000 p = namespace.Process(target=self.task)
2001 p.daemon = True
2002 p.start()
2003 threads.append(p)
2004
2005 def finalize(threads):
2006 for p in threads:
2007 p.join()
2008
2009 self._finalizer = weakref.finalize(self, finalize, threads)
2010
2011 def task(self):
2012 pid = os.getpid()

Callers 1

__init__Method · 0.45

Calls 7

DummyListMethod · 0.80
EventMethod · 0.80
setMethod · 0.45
ProcessMethod · 0.45
startMethod · 0.45
appendMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected