本文整理匯總了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