8000 gh-121464: Make concurrent iteration over enumerate safe under free-threading by eendebakpt · Pull Request #125734 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-121464: Make concurrent iteration over enumerate safe under free-threading #125734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10000
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
eendebakpt committed Jan 15, 2025
commit 9b400390edceea470c3ad7a5899f846b62ef0a11
6 changes: 3 additions & 3 deletions Lib/test/test_free_threading/test_enumerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EnumerateThreading(unittest.TestCase):
@threading_helper.reap_threads
@threading_helper.requires_working_threading()
def test_threading(self):
number_of_threads = 4
number_of_threads = 10
number_of_iterations = 8
n = 100
start = sys.maxsize - 40
Expand All @@ -23,8 +23,8 @@ def work(enum):
except StopIteration:
break

for _ in range(number_of_iterations):
enum = enumerate(range(start, start + n))
for it in range(number_of_iterations):
enum = enumerate(tuple(range(start, start + n)))
worker_threads = []
for ii in range(number_of_threads):
worker_threads.append(
Expand Down
1 change: 1 addition & 0 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ _Py_AddToAllObjects(PyObject *op)
void
_Py_NegativeRefcount(const char *filename, int lineno, PyObject *op)
{
printf("negative refcount for object of type %s\n", Py_TYPE(op)->tp_name);
_PyObject_AssertFailed(op, NULL, "object has negative ref count",
filename, lineno, __func__);
}
Expand Down
Loading
0