Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1855c21

Browse files
committed
Merged revisions 73077 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r73077 | r.david.murray | 2009-05-31 15:15:57 -0400 (Sun, 31 May 2009) | 4 lines Issue 3848: document the fact that epoll register raises an IOError if an fd is registered twice, and add some additional epoll tests. Patch by Christian Heimes. ........
1 parent a35f4b9 commit 1855c21

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

Doc/library/select.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ Edge and Level Trigger Polling (epoll) Objects
154154

155155
Register a fd descriptor with the epoll object.
156156

157+
.. note::
158+
159+
Registering a file descriptor that's already registered raises an
160+
IOError -- contrary to :ref:`poll-objects`'s register.
161+
157162

158163
.. method:: epoll.modify(fd, eventmask)
159164

Lib/test/test_epoll.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,34 @@ def test_add(self):
9595
finally:
9696
ep.close()
9797

98+
# adding by object w/ fileno works, too.
99+
ep = select.epoll(2)
100+
try:
101+
ep.register(server, select.EPOLLIN | select.EPOLLOUT)
102+
ep.register(client, select.EPOLLIN | select.EPOLLOUT)
103+
finally:
104+
ep.close()
105+
106+
ep = select.epoll(2)
107+
try:
108+
# TypeError: argument must be an int, or have a fileno() method.
109+
self.assertRaises(TypeError, ep.register, object(),
110+
select.EPOLLIN | select.EPOLLOUT)
111+
self.assertRaises(TypeError, ep.register, None,
112+
select.EPOLLIN | select.EPOLLOUT)
113+
# ValueError: file descriptor cannot be a negative integer (-1)
114+
self.assertRaises(ValueError, ep.register, -1,
115+
select.EPOLLIN | select.EPOLLOUT)
116+
# IOError: [Errno 9] Bad file descriptor
117+
self.assertRaises(IOError, ep.register, 10000,
118+
select.EPOLLIN | select.EPOLLOUT)
119+
# registering twice also raises an exception
120+
ep.register(server, select.EPOLLIN | select.EPOLLOUT)
121+
self.assertRaises(IOError, ep.register, server,
122+
select.EPOLLIN | select.EPOLLOUT)
123+
finally:
124+
ep.close()
125+
98126
def test_fromfd(self):
99127
server, client = self._connected_pair()
100128

0 commit comments

Comments
 (0)