python GIL
2024-01-05 本文已影响0人
michael_0x
今天跑python多线程出了个奇怪的crash:
Fatal Python error: PyThreadState_Get: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL)
找到如下参考:
https://superfastpython.com/thread-race-condition-shared-variable/
https://realpython.com/python-parallel-processing/
https://www.jianshu.com/p/573aaa001b35
然后研究了半天,发现是有个线程因为崩溃,导致了这个问题,然后崩溃的log也没有打出来,还以为是GIL的问题。
迫使自己看了下GIL,又多了解一个python的限制了。