if __name__ == '__main__':
    sem = multiprocessing.Semaphore()
with multiprocessing.Pool(initializer=init, initargs=(sem,)) as p:
    pass
Sharing a semaphore with a function using python multiprocessing