Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python的Multiprocessing.Process模块中,术语bootstrap指的是什么?_Python_Multiprocessing_Python Internals - Fatal编程技术网

在Python的Multiprocessing.Process模块中,术语bootstrap指的是什么?

在Python的Multiprocessing.Process模块中,术语bootstrap指的是什么?,python,multiprocessing,python-internals,Python,Multiprocessing,Python Internals,在多处理包中使用进程和池模块,并不断遇到对\u bootstrap方法的引用 从我看到的情况来看,该方法导入了一个多处理util.py模块,并使用它的方法(与其他一些方法相结合)来跟踪,记录和管理子进程 def _bootstrap(self): from . import util global _current_process try: self._children = set() self._counter = itertools.

在多处理包中使用进程和池模块,并不断遇到对
\u bootstrap
方法的引用

从我看到的情况来看,该方法导入了一个
多处理
util.py
模块,并使用它的方法(与其他一些方法相结合)来
跟踪
记录
管理
子进程

def _bootstrap(self):
    from . import util
    global _current_process

    try:
        self._children = set()
        self._counter = itertools.count(1)
        try:
            sys.stdin.close()
            sys.stdin = open(os.devnull)
        except (OSError, ValueError):
            pass
        _current_process = self
        util._finalizer_registry.clear()
        util._run_after_forkers()
        util.info('child process calling self.run()')
        try:
            self.run()
            exitcode = 0
        finally:
            util._exit_function()
    except SystemExit, e:
        if not e.args:
            exitcode = 1
        elif isinstance(e.args[0], int):
            exitcode = e.args[0]
        else:
            sys.stderr.write(str(e.args[0]) + '\n')
            sys.stderr.flush()
            exitcode = 1
    except:
        exitcode = 1
        import traceback
        sys.stderr.write('Process %s:\n' % self.name)
        sys.stderr.flush()
        traceback.print_exc()

    util.info('process exiting with exitcode %d' % exitcode)
    return exitcode
对术语“bootstrap”进行了一些研究,发现它在Python模块中的各种上下文中都有使用,并且最突出的是(除了twitter bootstrap框架之外)在统计中测量准确性的过程中


但在本例中,函数名似乎是指将各种元素连接在一起的方法?是这样吗?

引导功能是在创建后立即在
多处理进程内运行的。要么:

或:

传递给
进程的
目标
\u bootstrap
执行:

    try:
        self.run()  # This runs target.
        exitcode = 0
    finally:
        util._exit_function()
因此,本文中的“引导”是指。比如,当它启动时,第一件事就是负责启动你真正感兴趣的软件。对于
多处理
\u bootstrap
负责执行运行
目标
功能所需的设置,然后进行清理

def _main(fd):
    with os.fdopen(fd, 'rb', closefd=True) as from_parent:
        process.current_process()._inheriting = True
        try:
            preparation_data = pickle.load(from_parent)
            prepare(preparation_data)
            self = pickle.load(from_parent)
        finally:
            del process.current_process()._inheriting
    return self._bootstrap()
    try:
        self.run()  # This runs target.
        exitcode = 0
    finally:
        util._exit_function()