Coverage for src / mafw / tools / parallel.py: 82%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-30 16:10 +0000

1# Copyright 2025–2026 European Union 

2# Author: Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu) 

3# SPDX-License-Identifier: EUPL-1.2 

4""" 

5Utilities for parallel execution in MAFw. 

6 

7.. versionadded:: v2.1.0 

8 

9""" 

10 

11from __future__ import annotations 

12 

13import sys 

14 

15 

16def is_free_threading() -> bool: 

17 """Check if Python is running in free-threading mode. 

18 

19 This function inspects the Python interpreter to determine whether it is running 

20 in free-threading mode (also known as "nogil" or "free-threaded"), which disables 

21 the Global Interpreter Lock (GIL). 

22 

23 :return: True if the interpreter is running in free-threading mode, False otherwise. 

24 :rtype: bool 

25 """ 

26 is_gil_enabled = getattr(sys, '_is_gil_enabled', None) 

27 if is_gil_enabled: 27 ↛ 29line 27 didn't jump to line 29 because the condition on line 27 was always true

28 return not is_gil_enabled() 

29 return False 

30 

31 

32__all__ = ['is_free_threading'] 

33"""Public exports for the parallel utilities module."""