extmod/modselect: Properly track number of poll objects that are fd's.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2023-08-14 13:45:53 +10:00
parent 24a6e951ec
commit f6af48416d
3 changed files with 49 additions and 16 deletions

View File

@@ -77,7 +77,26 @@ try:
except OSError as er:
print("OSError", er.errno)
# Register then unregister a socket (a native stream), then test
# that the Python object is still pollable.
s2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
x.poll_state = _MP_STREAM_POLL_RD
poller.register(s2)
poller.unregister(s2)
print_poll_output(poller.poll())
# Test registering and unregistering multiple times.
for _ in range(2):
poller.unregister(s)
poller.unregister(x)
poller.register(s2)
poller.register(s, select.POLLIN)
poller.register(x, select.POLLIN)
poller.unregister(s2)
print_poll_output(poller.poll())
# Clean up.
poller.unregister(x)
poller.unregister(s)
s2.close()
s.close()

View File

@@ -9,3 +9,9 @@ CustomPollable.ioctl 3 1
[(<class 'CustomPollable'>, 1)]
CustomPollable.ioctl 3 1
OSError 1000
CustomPollable.ioctl 3 1
[(<class 'CustomPollable'>, 1)]
CustomPollable.ioctl 3 1
[(<class 'CustomPollable'>, 1)]
CustomPollable.ioctl 3 1
[(<class 'CustomPollable'>, 1)]