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


Python multiprocessing.RLock方法代码示例

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


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

示例1: initialize_unittest_logging

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def initialize_unittest_logging():
    # ACE is multi-process multi-threaded
    # so we use this special logging mechanism to keep a central repository of the log events generated
    # that the original process can access

    global test_log_manager
    global test_log_sync
    global test_log_messages
    global memory_log_handler

    test_log_manager = Manager()
    atexit.register(_atexit_callback)
    test_log_sync = RLock()
    test_log_messages = test_log_manager.list()

    log_format = logging.Formatter(datefmt='%(asctime)s')

    memory_log_handler = MemoryLogHandler()
    memory_log_handler.setLevel(logging.DEBUG)
    memory_log_handler.setFormatter(log_format)
    logging.getLogger().addHandler(memory_log_handler) 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:23,代码来源:test.py

示例2: _edit_lock

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def _edit_lock(self):
        # type: () -> ()
        if self.__edit_lock:
            return self.__edit_lock
        if not PROC_MASTER_ID_ENV_VAR.get() or len(PROC_MASTER_ID_ENV_VAR.get().split(':')) < 2:
            self.__edit_lock = RLock()
        elif PROC_MASTER_ID_ENV_VAR.get().split(':')[1] == str(self.id):
            # remove previous file lock instance, just in case.
            filename = os.path.join(gettempdir(), 'trains_{}.lock'.format(self.id))
            # noinspection PyBroadException
            try:
                os.unlink(filename)
            except Exception:
                pass
            # create a new file based lock
            self.__edit_lock = FileRLock(filename=filename)
        else:
            self.__edit_lock = RLock()
        return self.__edit_lock 
开发者ID:allegroai,项目名称:trains,代码行数:21,代码来源:task.py

示例3: __init__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def __init__(self, auth_handler, update_interval, accept_lang,
                 country_code, excluded_cars, save_car_details,
                 pin, save_path):

        self.__lock = RLock()
        self.accept_lang = accept_lang
        self.country_code = country_code
        self.auth_handler = auth_handler
        self.cars = []
        self.update_interval = update_interval
        self.excluded_cars = excluded_cars
        self.is_valid_session = False
        self.last_update_time = 0
        self.save_car_details = save_car_details
        self.save_path = save_path
        self.pin = pin
        self.region = "-an" if country_code == "US" else ""

        self.session = requests.session()
        # self.session.proxies.update(HTTP_PROXY)

        _LOGGER.debug("Controller init complete. Start _get_cars")
        self._get_cars() 
开发者ID:ReneNulschDE,项目名称:mbapipy,代码行数:25,代码来源:apicontroller.py

示例4: test_rlock

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def test_rlock(self):
        lock = self.RLock()
        self.assertEqual(lock.acquire(), True)
        self.assertEqual(lock.acquire(), True)
        self.assertEqual(lock.acquire(), True)
        self.assertEqual(lock.release(), None)
        self.assertEqual(lock.release(), None)
        self.assertEqual(lock.release(), None)
        self.assertRaises((AssertionError, RuntimeError), lock.release) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_multiprocessing.py

示例5: Value

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def Value(typecode_or_type, *args, **kwds):
    '''
    Return a synchronization wrapper for a Value
    '''
    lock = kwds.pop('lock', None)
    if kwds:
        raise ValueError('unrecognized keyword argument(s): %s' % kwds.keys())
    obj = RawValue(typecode_or_type, *args)
    if lock is False:
        return obj
    if lock in (True, None):
        lock = RLock()
    if not hasattr(lock, 'acquire'):
        raise AttributeError("'%r' has no method 'acquire'" % lock)
    return synchronized(obj, lock) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:sharedctypes.py

示例6: Array

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def Array(typecode_or_type, size_or_initializer, **kwds):
    '''
    Return a synchronization wrapper for a RawArray
    '''
    lock = kwds.pop('lock', None)
    if kwds:
        raise ValueError('unrecognized keyword argument(s): %s' % kwds.keys())
    obj = RawArray(typecode_or_type, size_or_initializer)
    if lock is False:
        return obj
    if lock in (True, None):
        lock = RLock()
    if not hasattr(lock, 'acquire'):
        raise AttributeError("'%r' has no method 'acquire'" % lock)
    return synchronized(obj, lock) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:sharedctypes.py

示例7: __init__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def __init__(self, obj, lock=None):
        self._obj = obj
        self._lock = lock or RLock()
        self.acquire = self._lock.acquire
        self.release = self._lock.release 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:sharedctypes.py

示例8: _start_io_tracker

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def _start_io_tracker():
    import multiprocessing

    global _track_io
    global _io_tracker_manager
    global _io_tracker_sync
    global _write_count
    global _read_count

    _io_tracker_manager = multiprocessing.Manager()
    _io_tracker_sync = multiprocessing.RLock()
    _write_count = _io_tracker_manager.Value('I', 0, lock=False)
    _read_count = _io_tracker_manager.Value('I', 0, lock=False)
    _track_io = True 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:16,代码来源:analysis.py

示例9: __init__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def __init__(self, io_):
        self.io = io_
        self._lock = multiprocessing.RLock()
        self._hook_called = multiprocessing.Value(ctypes.c_int, 0, lock=False)
        self._last_caller_pid = multiprocessing.Value(
            ctypes.c_int, -1, lock=False) 
开发者ID:chainer,项目名称:chainer,代码行数:8,代码来源:test_pickle_dataset.py

示例10: __init__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def __init__(self) -> None:
        self._hostResolvers = []
        # python dict structure is atomic for primitive actions. Need to be checked
        self._local_actor_refs = {}
        self._sequence_id = 0
        self._address = "nonhost"
        self._lock = RLock() 
开发者ID:AsynkronIT,项目名称:protoactor-python,代码行数:9,代码来源:process.py

示例11: __init__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def __init__(self, log_client, heartbeat_interval, consumer_group_time_out):
        super(ConsumerHeatBeat, self).__init__()
        self.log_client = log_client
        self.heartbeat_interval = heartbeat_interval
        self.mheld_shards = []
        self.mheart_shards = []
        self.shut_down_flag = False
        self.lock = RLock()
        self.last_hearbeat_successed_unixtime = time.time()
        self.consumer_group_time_out = consumer_group_time_out
        self.logger = HeartBeatLoggerAdapter(
            logging.getLogger(__name__), {"heart_beat": self}) 
开发者ID:aliyun,项目名称:aliyun-log-python-sdk,代码行数:14,代码来源:heart_beat.py

示例12: __init__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def __init__(self, loghub_client_adapter, consumer_name, shard_id):
        self.consumer_group_client = loghub_client_adapter
        self.consumer_name = consumer_name
        self.shard_id = shard_id
        self.last_check_time = time.time()
        self.cursor = ''
        self.temp_check_point = ''
        self.last_persistent_checkpoint = ''
        self.default_flush_check_point_interval = 60
        self.lock = RLock() 
开发者ID:aliyun,项目名称:aliyun-log-python-sdk,代码行数:12,代码来源:checkpoint_tracker.py

示例13: create_mp_lock

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def create_mp_lock(cls, name, is_rlock):
        if not hasattr(cls, name):
            try:
                if is_rlock:
                    setattr(cls, name, mp.RLock())  # multiprocessing lock
                else:
                    setattr(cls, name, mp.Lock())  # multiprocessing lock
            except ImportError:  # pragma: no cover
                setattr(cls, name, None)
            except OSError:  # pragma: no cover
                setattr(cls, name, None) 
开发者ID:thu-coai,项目名称:tatk,代码行数:13,代码来源:lock.py

示例14: create_th_lock

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def create_th_lock(cls, name, is_rlock):
        if not hasattr(cls, name):
            try:
                if is_rlock:
                    setattr(cls, name, th.RLock())  # thread lock
                else:
                    setattr(cls, name, th.Lock())  # thread lock
            except OSError:  # pragma: no cover
                setattr(cls, name, None) 
开发者ID:thu-coai,项目名称:tatk,代码行数:11,代码来源:lock.py

示例15: __init__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import RLock [as 别名]
def __init__(self, directory, **kwargs):
        """
        :param directory: root dir for storage
        """
        super(FileSystemResourceAPI, self).__init__(**kwargs)
        self.directory = directory
        self.base_path = os.path.join(self.directory, self.name)
        self._join_path = partial(os.path.join, self.base_path)
        self._lock = RLock() 
开发者ID:apache,项目名称:incubator-ariatosca,代码行数:11,代码来源:filesystem_rapi.py


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