Hacker News new | ask | show | jobs
by Animats 1220 days ago
Me too, but threading is botched in Python. Not just the Global Interpreter Lock. Some Python packages are not thread-safe, and it's not documented which ones are not. Years ago I discovered that CPickle was not thread safe, and that wasn't considered a problem.
1 comments

Since the GIL is there and it restricts multithreaded issues to happen, why would python packages be thread-safe?
You can still have thread safety issues with the GIL in place, because globals and other data is shared between threads.

For example, you can put a dictionary at the module level, thread A can set a key in that dictionary like “name”, thread B can overwrite it, and then thread A comes back, does dct[“name”] and gets an unexpected answer.

This is a relatively easy mistake to make, a lot of python code has module level variables.