当前位置: 首页>>代码示例>>Python>>正文


Python process.ORIGINAL_DIR属性代码示例

本文整理汇总了Python中multiprocessing.process.ORIGINAL_DIR属性的典型用法代码示例。如果您正苦于以下问题:Python process.ORIGINAL_DIR属性的具体用法?Python process.ORIGINAL_DIR怎么用?Python process.ORIGINAL_DIR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在multiprocessing.process的用法示例。


在下文中一共展示了process.ORIGINAL_DIR属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_preparation_data

# 需要导入模块: from multiprocessing import process [as 别名]
# 或者: from multiprocessing.process import ORIGINAL_DIR [as 别名]
def get_preparation_data(name):
        '''
        Return info about parent needed by child to unpickle process object
        '''
        from .util import _logger, _log_to_stderr

        d = dict(
            name=name,
            sys_path=sys.path,
            sys_argv=sys.argv,
            log_to_stderr=_log_to_stderr,
            orig_dir=process.ORIGINAL_DIR,
            authkey=process.current_process().authkey,
            )

        if _logger is not None:
            d['log_level'] = _logger.getEffectiveLevel()

        if not WINEXE and not WINSERVICE and \
           not d['sys_argv'][0].lower().endswith('pythonservice.exe'):
            main_path = getattr(sys.modules['__main__'], '__file__', None)
            if not main_path and sys.argv[0] not in ('', '-c'):
                main_path = sys.argv[0]
            if main_path is not None:
                if not os.path.isabs(main_path) and \
                                          process.ORIGINAL_DIR is not None:
                    main_path = os.path.join(process.ORIGINAL_DIR, main_path)
                d['main_path'] = os.path.normpath(main_path)

        return d

    #
    # Make (Pipe)Connection picklable
    # 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:36,代码来源:forking.py

示例2: get_preparation_data

# 需要导入模块: from multiprocessing import process [as 别名]
# 或者: from multiprocessing.process import ORIGINAL_DIR [as 别名]
def get_preparation_data(name):
        '''
        Return info about parent needed by child to unpickle process object
        '''
        from .util import _logger, _log_to_stderr

        d = dict(
            name=name,
            sys_path=sys.path,
            sys_argv=sys.argv,
            log_to_stderr=_log_to_stderr,
            orig_dir=process.ORIGINAL_DIR,
            authkey=process.current_process().authkey,
            )

        if _logger is not None:
            d['log_level'] = _logger.getEffectiveLevel()

        if not WINEXE and not WINSERVICE:
            main_path = getattr(sys.modules['__main__'], '__file__', None)
            if not main_path and sys.argv[0] not in ('', '-c'):
                main_path = sys.argv[0]
            if main_path is not None:
                if not os.path.isabs(main_path) and \
                                          process.ORIGINAL_DIR is not None:
                    main_path = os.path.join(process.ORIGINAL_DIR, main_path)
                d['main_path'] = os.path.normpath(main_path)

        return d

    #
    # Make (Pipe)Connection picklable
    # 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:35,代码来源:forking.py

示例3: prepare

# 需要导入模块: from multiprocessing import process [as 别名]
# 或者: from multiprocessing.process import ORIGINAL_DIR [as 别名]
def prepare(data):
    '''
    Try to get current process ready to unpickle process object
    '''
    if 'name' in data:
        process.current_process().name = data['name']

    if 'authkey' in data:
        process.current_process().authkey = data['authkey']

    if 'log_to_stderr' in data and data['log_to_stderr']:
        util.log_to_stderr()

    if 'log_level' in data:
        util.get_logger().setLevel(data['log_level'])

    if 'log_fmt' in data:
        import logging
        util.get_logger().handlers[0].setFormatter(
            logging.Formatter(data['log_fmt'])
        )

    if 'sys_path' in data:
        sys.path = data['sys_path']

    if 'sys_argv' in data:
        sys.argv = data['sys_argv']

    if 'dir' in data:
        os.chdir(data['dir'])

    if 'orig_dir' in data:
        process.ORIGINAL_DIR = data['orig_dir']

    if 'mp_tracker_args' in data:
        from multiprocessing.resource_tracker import (
            _resource_tracker as mp_resource_tracker
        )
        mp_resource_tracker._fd = data['mp_tracker_args']['fd']
        mp_resource_tracker._pid = data['mp_tracker_args']['pid']
    if 'tracker_args' in data:
        from .resource_tracker import _resource_tracker
        _resource_tracker._pid = data["tracker_args"]['pid']
        if sys.platform == 'win32':
            handle = data["tracker_args"]["fh"]
            _resource_tracker._fd = msvcrt.open_osfhandle(handle, 0)
        else:
            _resource_tracker._fd = data["tracker_args"]["fd"]

    if 'init_main_from_name' in data:
        _fixup_main_from_name(data['init_main_from_name'])
    elif 'init_main_from_path' in data:
        _fixup_main_from_path(data['init_main_from_path'])


# Multiprocessing module helpers to fix up the main module in
# spawned subprocesses 
开发者ID:joblib,项目名称:loky,代码行数:59,代码来源:spawn.py


注:本文中的multiprocessing.process.ORIGINAL_DIR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。