New GitHub issue #95600 from yuyupopo:<br>
<hr>
<pre>
<!--
If you're new to Python and you're not sure whether what you're experiencing is a bug, the CPython issue tracker is not
the right place to seek help. Consider the following options instead:
- reading the Python tutorial: https://docs.python.org/3/tutorial/
- posting in the "Users" category on discuss.python.org: https://discuss.python.org/c/users/7
- emailing the Python-list mailing list: https://mail.python.org/mailman/listinfo/python-list
- searching our issue tracker (https://github.com/python/cpython/issues) to see if
your problem has already been reported
-->
# Bug report
I think the `selectors.KqueueSelector`, and `selectors.PollSelector` behave differently in Mac OS X.
I tested the following code in Python 3.10.4, Mac OS X (12.5) Apple Sillicon.
Below is a simple code that creates a named pipe, opens two descriptors for read (non-block) and write(non-block).
I register a `EVENT_READ` event on the read file descriptor, and write some message bytes to the pipe.
When the message is small (<8192 b), both `Kqueue` and `Poll` invokes a `selector` event.
However, for large messages, `Poll` works, but hangs with `Kqueue`.
```python
import os
import selectors
def test_should_return(selector: selectors.BaseSelector, msg: bytes):
pipe = "pipe.fifo"
os.mkfifo(pipe)
f1 = os.open(pipe, os.O_RDONLY | os.O_NONBLOCK)
f2 = os.open(pipe, os.O_WRONLY | os.O_NONBLOCK)
try:
selector.register(f1, selectors.EVENT_READ)
os.write(f2, msg)
assert selector.select() # should return as pipe can be read now
print("Passed!")
finally:
os.close(f1)
os.close(f2)
os.remove(pipe)
test_should_return(selectors.PollSelector(), b"m") # Passes
test_should_return(selectors.KqueueSelector(), b"m") # Passes
test_should_return(selectors.PollSelector(), b"m" * 10000) # Passes
test_should_return(selectors.KqueueSelector(), b"m" * 10000) # Hangs
```
# Your environment
Python 3.10.4, Mac OS X (12.5) Apple Sillicon.
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/95600">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>