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


Python managers.BaseManager方法代码示例

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


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

示例1: get

# 需要导入模块: from multiprocessing import managers [as 别名]
# 或者: from multiprocessing.managers import BaseManager [as 别名]
def get(ip, authkey):
    ''' gets a remote queue on another ip '''
    class RManager(BaseManager):
        ''' manager which connects to a remote queue '''
        pass
    RManager.register('getQueue')
    current_manager = RManager(address=(ip,PORT), authkey=authkey)
    current_manager.connect()
    return current_manager.getQueue() 
开发者ID:shariq,项目名称:burgundy,代码行数:11,代码来源:remotequeue.py

示例2: make

# 需要导入模块: from multiprocessing import managers [as 别名]
# 或者: from multiprocessing.managers import BaseManager [as 别名]
def make(authkey, public=True):
    ''' makes a remote queue and returns it '''
    class QManager(BaseManager):
        ''' manager of a remote queue '''
        pass
    queue = Queue()
    QManager.register('getQueue', callable=lambda:queue)
    ip = '0.0.0.0' if public else 'localhost'
    qm = QManager(address=(ip, PORT), authkey=authkey)
    qm.start()
    tokens = [random.choice('abcde') for x in range(14)]
    random_token = 'x'.join(tokens)
    globals()['raNdDOmHAkkC82492'] = qm
    return queue 
开发者ID:shariq,项目名称:burgundy,代码行数:16,代码来源:remotequeue.py

示例3: main

# 需要导入模块: from multiprocessing import managers [as 别名]
# 或者: from multiprocessing.managers import BaseManager [as 别名]
def main():
    manager = BaseManager()
    manager.register('Employee', Employee)
    manager.start()
    em = manager.Employee('zhangsan', 1000)
    lock = Lock()
    proces = [Process(target=func1, args=(em, lock)) for i in range(10)]
    for p in proces:
        p.start()
    for p in proces:
        p.join()
    print((em.getPay())) 
开发者ID:deepdiy,项目名称:deepdiy,代码行数:14,代码来源:manager_in_multiprocess.py

示例4: _get_manager_class

# 需要导入模块: from multiprocessing import managers [as 别名]
# 或者: from multiprocessing.managers import BaseManager [as 别名]
def _get_manager_class(self, register_callables=False):
        """
        Returns a new 'Manager' subclass with registered methods.
        If 'register_callable' is True, defines the 'callable' arguments.
        """

        class _EvaluatorSyncManager(managers.BaseManager):
            """
            A custom BaseManager.
            Please see the documentation of `multiprocessing` for more
            information.
            """
            pass

        inqueue = queue.Queue()
        outqueue = queue.Queue()
        namespace = Namespace()

        if register_callables:
            _EvaluatorSyncManager.register(
                "get_inqueue",
                callable=lambda: inqueue,
                )
            _EvaluatorSyncManager.register(
                "get_outqueue",
                callable=lambda: outqueue,
                )
            _EvaluatorSyncManager.register(
                "get_state",
                callable=self._get_secondary_state,
                )
            _EvaluatorSyncManager.register(
                "set_state",
                callable=lambda v: self._secondary_state.set(v),
                )
            _EvaluatorSyncManager.register(
                "get_namespace",
                callable=lambda: namespace,
                )
        else:
            _EvaluatorSyncManager.register(
                "get_inqueue",
                )
            _EvaluatorSyncManager.register(
                "get_outqueue",
                )
            _EvaluatorSyncManager.register(
                "get_state",
                )
            _EvaluatorSyncManager.register(
                "set_state",
                )
            _EvaluatorSyncManager.register(
                "get_namespace",
                )
        return _EvaluatorSyncManager 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:58,代码来源:distributed.py


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