Skip to content

OSError 9 when using KqueueSelector and multiprocessing #111395

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

Closed
Emru1 opened this issue Oct 27, 2023 · 2 comments
Closed

OSError 9 when using KqueueSelector and multiprocessing #111395

Emru1 opened this issue Oct 27, 2023 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@Emru1
Copy link

Emru1 commented Oct 27, 2023

Bug report

Bug description:

KqueueSelector fails when created in parent process and used in child process with an OSError 9.
Tested on FreeBSD 13 and Python 3.9
I am not sure if this is relatable to #110395

import selectors
import multiprocessing

class Test(multiprocessing.Process):
    def __init__(self):
        super().__init__()
        self.s = selectors.KqueueSelector()

    def run(self):
        self.s.select()

if __name__ == '__main__':
    t = Test()
    t.start()
Process Test-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/n/home/emru/test.py", line 10, in run
    self.s.select()
  File "/usr/local/lib/python3.9/selectors.py", line 562, in select
    kev_list = self._selector.control(None, max_ev, timeout)
OSError: [Errno 9] Bad file descriptor

CPython versions tested on:

3.9

Operating systems tested on:

Other

### Tasks
@Emru1 Emru1 added the type-bug An unexpected behavior, bug, or error label Oct 27, 2023
@ronaldoussoren
Copy link
Contributor

This is a duplicate of #110395, which mentions the root cause for the error.

@ronaldoussoren ronaldoussoren closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
@ronaldoussoren
Copy link
Contributor

To expand on my previous message (and phrase it correctly):

This is related of #110395, but slightly different. The system kqueue API does not support creating the kqueue in a parent proces and use it in a child. That's not something we can work around.

That means that your code will give an error even if the #110395 is fixed (the PR on that issue will close all kqueue objects in the child proces).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants