classification
Title: select.devpoll objects have no close() method
Type: Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: haypo, jcea, neologix, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-08-20 22:20 by haypo, last changed 2013-08-21 22:21 by haypo. This issue is now closed.

Files
File name Uploaded Description Edit
devpoll_close.patch haypo, 2013-08-21 10:23 review
devpoll_close-2.patch haypo, 2013-08-21 18:19 review
Messages (10)
msg195721 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2013-08-20 22:20
select.epoll and select.kqueue objects have a close() method, but not select.poll objects, whereas all these objects store internally a file descriptor.

select.poll lacks also a fileno() method.

I added the fileno() method in my implementation of the PEP 446 (see issue #18571).
msg195723 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2013-08-20 22:21
See also issue #16853 "add a Selector to the select module".
msg195725 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-08-20 22:33
This all sounds fine to fix without waiting for anything else -- can you attach a patch here?
msg195748 - (view) Author: Charles-Fran├žois Natali (neologix) * (Python committer) Date: 2013-08-21 07:05
Just to be explicit (there are typos in Victor's original messages): it's about select.devpoll, for Solaris-derivatives with /dev/poll, and not for select.poll, based on poll() syscall.
msg195757 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2013-08-21 09:25
"Just to be explicit (there are typos in Victor's original messages): it's about select.devpoll, for Solaris-derivatives with /dev/poll, and not for select.poll, based on poll() syscall."

Oops sorry, yes, I'm talking about select.devpoll, its structure has a "int fd_devpoll;" field:

typedef struct {
    PyObject_HEAD
    int fd_devpoll;
    int max_n_fds;
    int n_fds;
    struct pollfd *fds;
} devpollObject;
msg195765 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2013-08-21 10:23
"This all sounds fine to fix without waiting for anything else -- can you attach a patch here?"

I opened the issue as a reminder for me. Here is a patch.

 * Add close() and fileno() methods and a closed attribute (property) to devpoll object
 * Document closed attribute of epoll and kqueue objects
 * Add tests on closed object for devpoll, epoll and kqueue. There was no test for devpoll, epoll nor kqueue :-(

select.poll is still not tested. We should add much more tests, especially tests checking than a fd becomes ready for each implementation. We may develop these tests using #16853 ?

I ran test_select on Linux, so I only checked the epoll unit test.

The "closed" attribute of epoll and kqueue objects should also be documented in Python 2.7 and 3.3.
msg195771 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-08-21 10:58
poll, devpoll, epoll and kqueue are tested in test_poll.py, test_devpoll.py, test_epoll.py and test_kqueue.py test files.
msg195814 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2013-08-21 18:19
Updated patch: move tests to the right test files and test that close() can be called more than once.
msg195826 - (view) Author: Roundup Robot (python-dev) Date: 2013-08-21 22:21
New changeset ccbe2132392b by Victor Stinner in branch 'default':
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
http://hg.python.org/cpython/rev/ccbe2132392b
msg195827 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2013-08-21 22:21
Charles-Fran├žois Natali and Guido van Rossum: thanks for your reviews ;-)
History
Date User Action Args
2013-08-21 22:21:47hayposetmessages: + msg195827
2013-08-21 22:21:04python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg195826

resolution: fixed
stage: needs patch -> resolved
2013-08-21 18:48:03gvanrossumsetnosy: - gvanrossum
2013-08-21 18:19:34hayposetfiles: + devpoll_close-2.patch

messages: + msg195814
2013-08-21 10:58:38serhiy.storchakasetmessages: + msg195771
2013-08-21 10:23:16hayposetfiles: + devpoll_close.patch
keywords: + patch
messages: + msg195765
2013-08-21 09:41:00serhiy.storchakasetnosy: + serhiy.storchaka

stage: needs patch
2013-08-21 09:25:55hayposetmessages: + msg195757
2013-08-21 07:05:54neologixsetmessages: + msg195748
2013-08-21 04:10:21jceasetnosy: + jcea
2013-08-20 22:33:53gvanrossumsetmessages: + msg195725
2013-08-20 22:21:50hayposetmessages: + msg195723
2013-08-20 22:20:01haypocreate