Skip to content

gh-151364: Add critical sections to kqueue#151376

Open
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:kqueue_critical_section
Open

gh-151364: Add critical sections to kqueue#151376
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:kqueue_critical_section

Conversation

@vstinner

@vstinner vstinner commented Jun 11, 2026

Copy link
Copy Markdown
Member

@vstinner

Copy link
Copy Markdown
Member Author

The bug report was only on .close() and closed, but I also added critical sections on __init__(), repr() and richcompare.

cc @kumaraditya303

Comment thread Modules/selectmodule.c
Comment on lines +1993 to +2001
static int
kqueue_event_init(PyObject *op, PyObject *args, PyObject *kwds)
{
int res;
Py_BEGIN_CRITICAL_SECTION(self);
res = kqueue_event_init_lock_held(op, args, kwds);
Py_END_CRITICAL_SECTION();
return res;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We very rarely add locking to __init__ functions because there are few reasons to support concurrent reinitialization on a live object, and it slows the single-threaded case.

@@ -0,0 +1,2 @@
Add critical sections to :func:`select.kqueue` objects. Patch by Victor

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do users know what "critical sections" mean in this case? It's probably better to say something like "Fix thread-safety issues in select.kqueue objects," because that's what users care more about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants