Hacker News new | ask | show | jobs
by jsyolo 1220 days ago
Since the GIL is there and it restricts multithreaded issues to happen, why would python packages be thread-safe?
1 comments

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.