Signalfd and select could probably be made to work if one codes around the race conditions pselect is provided to avoid. I’m not sure if using the GIL (for CPython) is sufficient or if a dedicated concurrency control (e.g. lock, mutex, semaphore) is necessary.
An alternative is to call the C library function via a wrapper. I had need to use setfsuid on a project a couple of years ago and found this example: https://gist.github.com/atdt/ebafa299e843a767139b From: Python-list <python-list-bounces+gweatherby=uchc....@python.org> on behalf of Barry <ba...@barrys-emacs.org> Date: Friday, December 2, 2022 at 7:02 PM To: Ian Pilcher <arequip...@gmail.com> Cc: python-list@python.org <python-list@python.org> Subject: Re: Calling pselect/ppoll/epoll_pwait *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** > On 2 Dec 2022, at 20:03, Ian Pilcher <arequip...@gmail.com> wrote: > > Does Python provide any way to call the "p" variants of the I/O > multiplexing functions? > > Looking at the documentation of the select[1] and selectors[2] modules, > it appears that they expose only the "non-p" variants. > > [1] > https://urldefense.com/v3/__https://docs.python.org/3/library/select.html__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_OD5qBjeA$<https://urldefense.com/v3/__https:/docs.python.org/3/library/select.html__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_OD5qBjeA$> > [2] > https://urldefense.com/v3/__https://docs.python.org/3/library/selectors.html__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_MwNjgO8A$<https://urldefense.com/v3/__https:/docs.python.org/3/library/selectors.html__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_MwNjgO8A$> Can you use signalfd and select/poll/epoll? Barry > > -- > ======================================================================== > Google Where SkyNet meets Idiocracy > ======================================================================== > -- > https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_PhasKBfg$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_PhasKBfg$> > -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_PhasKBfg$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_PhasKBfg$> -- https://mail.python.org/mailman/listinfo/python-list