728x90
반응형
다음과 같은 경고가 PySide에서 multi-thread 를 이용할 때 발생할 수 있음:
(pyside) D:\dsaint31\pyqt6> cmd /C "C:\Users\GC\miniconda3\envs\pyside\python.exe c:\Users\GC\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64\bundled\libs\debugpy\launcher 10576
-- D:\dsaint31\pyqt6\ds_tp.py "
<frozen importlib._bootstrap>:491: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'shiboken6.Shiboken', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
Python 3.13 이상을 사용하면서 내부 C 확장 모듈을 사용하는 라이브러리를 실행할 때 아주 흔하게 발생 .
경고가 발생한 이유
- 파이썬은 본래 한 번에 하나의 스레드만 실행되도록 제어하는 GIL을 사용해 왔음.
- 이는 성능 저하의 원인이 되기도 하여,
- 최근 파이썬 버전에서는 성능 향상을 위해 이 GIL을 끄고 실행할 수 있는 '프리-스레딩(Free-threaded)' 모드가 도입됨.
위의 경고는
- 현재 실행 중인 파이썬 환경이 GIL을 비활성화한 상태(또는 비활성화할 수 있는 상태)인데,
- PySide의 핵심 구동 엔진인 "Shiboken 라이브러리가 아직 GIL 없이 완벽하게 안전하게 돌아갈 준비가 안 되어있기 때문에".
- GIL를 자동으로 다시 활성화하여 프로그램을 실행했다는 메시지임.
GIL 활성화 여부 확인 코드
다음의 코드로 GIL 활성화 여부를 확인할 수 있음.
아래 코드는
파이썬이 현재 프리-스레딩(Free-threaded, No-GIL) 모드로
동작 중인지 확인가능함.
import sys
def check_free_threading():
print(f"현재 파이썬 버전: {sys.version.split()[0]}")
# sys._is_gil_enabled() 함수는 Python 3.13 이상에서 지원됩니다.
if hasattr(sys, "_is_gil_enabled"):
gil_enabled = sys._is_gil_enabled()
if gil_enabled:
print("상태: GIL이 활성화되어 있습니다. (표준 멀티스레딩 모드)")
else:
print("상태: GIL이 비활성화되었습니다! (Free-threaded / No-GIL 모드)")
else:
print("상태: 표준 파이썬 모드 (Python 3.13 미만 버전은 프리-스레딩을 지원하지 않음)")
if __name__ == "__main__":
check_free_threading()
같이보면 좋은 자료들
2026.06.01 - [Python] - Lock and GIL
Lock and GIL
GIL (Global Interpreter Lock) GIL을 이해하려면 먼저 lock의 개념부터 짚어야 하므로,lock 에 대한 설명과 synchronous object에 대한 소개를 하고 나서 GIL을 다룸.Lock이란Lock (잠금):여러 thread가 동시에 공유 자
ds31x.tistory.com
728x90
'Errors' 카테고리의 다른 글
| Whale: Google docs 인쇄 오류 (1) | 2026.04.26 |
|---|---|
| Gemini CLI - /restore 동작 안함 : macOS (0) | 2025.12.28 |
| [Error] WSL: 0x8004032d / 0x800000d (0) | 2024.07.04 |
| [macOS] Unable to find Python library directory. Use a framework build of Python. : PySide6 (0) | 2024.03.03 |
| [vscode] Python F5 로 수행시 에러: E+00000.078: Error while enumerating installed packages. (1) | 2024.02.05 |