I need to do some multiprocessing with my Python scripts and I decided to give it a try with Google's collaboratory.
I've connected to local runtime and tried to run the following script:
import multiprocessing
def spawn(num):
print('Spawned! {}'.format(num))
if __name__ == '__main__':
for i in range(5):
p = multiprocessing.Process(target=spawn, args=(i,))
p.start()
However, when I run this, nothing happens. Absolutely nothing, no errors, no prints, it just executes instantly and that's it.
Am I missing something? Does multiprocessing work with Google Colab local runtime?
Thanks in advance.
Run this instead
import multiprocessing
def spawn(num):
print('Spawned! {}'.format(num))
for i in range(5):
p = multiprocessing.Process(target=spawn, args=(i,))
p.start()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.