當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。