brainpy.running.process_pool_lock

brainpy.running.process_pool_lock(func, all_net_params, nb_process)[source]

Run multiple models in multi-processes with lock.

Sometimes, you want to synchronize the processes. For example, if you want to write something in a document, you cannot let multi-process simultaneously open this same file. So, you need add a lock argument in your defined func:

In such case, you can use process_pool_lock() to run your model.

Parameters
  • func (callable) – The function to run model.

  • all_net_params (a_list, tuple) – The parameters of the function arguments.

  • nb_process (int) – The number of the processes.

Returns

results – Process results.

Return type

list