Multiprocessing and random()
Let’s say, for some odd reason, you’re hosting a Python service that:
- takes requests that run large computations based on a randomly generated number (a “seed”)
- spreads work across multiple workers to handle many requests
Then, it’s likely you’ll introduce a subtle randomness bug that leads to duplicate seeds appearing. Let me explain:
