File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414# ==============================================================================
15+
16+ import atexit
17+ import sys
18+
19+ import pytest
20+
21+ from helpers import (
22+ PYPY ,
23+ WASM ,
24+ Py_DEBUG ,
25+ Py_GIL_DISABLED ,
26+ )
27+
28+
29+ if PYPY or WASM or sys .version_info < (3 , 14 ):
30+ pytest .skip ('Test for CPython 3.14+ only' , allow_module_level = True )
31+
32+
33+ from concurrent .futures import InterpreterPoolExecutor
34+
35+
36+ if Py_GIL_DISABLED and not Py_DEBUG :
37+ NUM_WORKERS = 32
38+ NUM_FUTURES = 128
39+ else :
40+ NUM_WORKERS = 4
41+ NUM_FUTURES = 16
42+
43+
44+ EXECUTOR = InterpreterPoolExecutor (max_workers = NUM_WORKERS )
45+ atexit .register (EXECUTOR .shutdown )
46+
47+
48+ def run (func , / , * args , ** kwargs ):
49+ future = EXECUTOR .submit (func , * args , ** kwargs )
50+ exception = future .exception ()
51+ if exception is not None :
52+ raise exception
53+ return future .result ()
You can’t perform that action at this time.
0 commit comments