本文整理汇总了Python中multiprocess.Manager方法的典型用法代码示例。如果您正苦于以下问题:Python multiprocess.Manager方法的具体用法?Python multiprocess.Manager怎么用?Python multiprocess.Manager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocess
的用法示例。
在下文中一共展示了multiprocess.Manager方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_sub_mock
# 需要导入模块: import multiprocess [as 别名]
# 或者: from multiprocess import Manager [as 别名]
def on_sub_mock(mocker):
mgr = multiprocess.Manager()
q = mgr.Queue()
def on_subscribe(self, msg, params, websocket):
new_params = copy.deepcopy(params)
new_params.update({'context': msg.get('context', {})})
q.put(self)
return new_params
on_sub_mock = {
'on_subscribe':
PickableMock(side_effect=promisify(on_subscribe), name='on_subscribe')
}
return on_sub_mock, q
示例2: __init__
# 需要导入模块: import multiprocess [as 别名]
# 或者: from multiprocess import Manager [as 别名]
def __init__(self, task_data={}):
self.id = str(uuid.uuid4())
self.data = task_data
self.process = None
manager = multiprocess.Manager()
self.status_dict = manager.dict()
self.set_status('')
self.logs = manager.list()
self.logger = utilities.create_logger(self.id)
示例3: __init__
# 需要导入模块: import multiprocess [as 别名]
# 或者: from multiprocess import Manager [as 别名]
def __init__(self, filename, mode):
logging.Handler.__init__(self)
self.handler = logging.FileHandler(filename, mode)
manager = multiprocess.Manager()
self.queue = manager.Queue(-1)
# self.queue = multiprocess.Queue(-1)
self.is_closed = False
self.t = threading.Thread(target=self.receive)
self.t.daemon = True
self.t.start()
示例4: options_mocks
# 需要导入模块: import multiprocess [as 别名]
# 或者: from multiprocess import Manager [as 别名]
def options_mocks(mocker):
mgr = multiprocess.Manager()
q = mgr.Queue()
def on_subscribe(self, msg, params, websocket):
new_params = copy.deepcopy(params)
new_params.update({'context': msg.get('context', {})})
q.put(self)
return new_params
def on_connect(self, message, websocket):
q.put(self)
def on_disconnect(self, websocket):
q.put(self)
def on_unsubscribe(self, websocket):
q.put(self)
options_mocks = {
'on_subscribe':
PickableMock(side_effect=promisify(on_subscribe), name='on_subscribe'),
'on_unsubscribe':
PickableMock(side_effect=on_unsubscribe, name='on_unsubscribe'),
'on_connect':
PickableMock(
return_value={'test': 'test_context'},
side_effect=on_connect,
name='on_connect'),
'on_disconnect':
PickableMock(side_effect=on_disconnect, name='on_disconnect')
}
return options_mocks, q