FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.15] Use _testlimitedcapi in test_free_threading.test_capi (#158935) by vstinner · Pull Request #159146 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 5 additions & 6 deletions Lib/test/test_free_threading/test_capi.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import ctypes
import sys
import unittest

from test.support import import_helper
from test.support import threading_helper
from test.support.threading_helper import run_concurrently


_PyImport_AddModuleRef = ctypes.pythonapi.PyImport_AddModuleRef
_PyImport_AddModuleRef.argtypes = (ctypes.c_char_p,)
_PyImport_AddModuleRef.restype = ctypes.py_object
# Skip the test if the extension is missing
_testlimitedcapi = import_helper.import_module('_testlimitedcapi')


@threading_helper.requires_working_threading()
Expand All @@ -20,13 +18,14 @@ def test_pyimport_addmoduleref_thread_safe(self):
NUM_ITERS = 10
NTHREADS = 4

PyImport_AddModuleRef = _testlimitedcapi.PyImport_AddModuleRef
module_name = f"test_free_threading_addmoduleref_{id(self)}"
module_name_bytes = module_name.encode()
sys.modules.pop(module_name, None)
results = []

def worker():
module = _PyImport_AddModuleRef(module_name_bytes)
module = PyImport_AddModuleRef(module_name_bytes)
results.append(module)

for _ in range(NUM_ITERS):
Expand Down
Loading

Back | FazBrowse Home | New Git URL