A process cannot start here, but pickling can be studied
OSError is the browser sandbox saying it cannot create processes. The rest shows the isolation: the worker gets a copy.
multiprocessing runs your Python code in separate processes, each with its own interpreter, its own GIL and its own memory, so CPU-bound work can use every core. The price is that arguments and results are copied by pickling, and your script must be safe to import again.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write a top-level function cube(n) and show that pickle.loads(pickle.dumps(cube)) returns the same function. (In a script run as python file.py.)
Use functools.partial to make a picklable version of lambda x: pow(x, 3) and call it on 4 after a pickle round trip.
Write a function is_picklable(obj) that returns True or False, and test it on a list and on a threading.Lock().
Explain it without notes
How is a process different from a thread, and why does multiprocessing get around the GIL?
Why must arguments to a worker process be picklable, and which common things are not?
What is the if __name__ == "__main__": guard for in multiprocessing code?
Explain spawn, fork and forkserver, and say which defaults apply.
A function running inside pool.map raises ValueError. What does the parent program see, and how does the rest of the pool behave?
Expected output
OSError: [Errno 52] Function not implemented
parent's list: ['a', 'b']
worker's reply: ['a', 'b', 'worker was here']