Hacker News new | ask | show | jobs
by slt2021 1057 days ago
so Thread based based pool will have same instance of generator, while Process based pool with have unique instance of generator?
2 comments

In this example, calling sum() creates a generator and returns it. Say g = sum(). If you share g between threads, they will all use the same generator object! If you call sum() separately per thread, they will be different generators.

If you try to send g to a different process, you will get an error, because it doesn't serialize.

I don't know if a generator can be shared across threads, but in that case ... I have no idea :/

You'll need to search, or try!