本文整理汇总了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()
示例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
示例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()))
示例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