- brainpy.running.process_pool_lock(func, all_params, num_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 multiprocess simultaneously open this same file. So, you need add a lock argument in your defined func:
def some_func(..., lock, ...): ... do something .. lock.acquire() ... something cannot simultaneously do by multi-process .. lock.release()
In such case, you can use process_pool_lock() to run your model.
This multiprocessing function should be called within a if __main__ == ‘__main__’: syntax.