cpython: d6f61cd364d9 (original) (raw)
Mercurial > cpython
changeset 80863:d6f61cd364d9
Issue #16488: epoll() objects now support the `with` statement. Patch by Serhiy Storchaka. [#16488]
Antoine Pitrou solipsis@pitrou.net | |
---|---|
date | Sat, 15 Dec 2012 21:14:21 +0100 |
parents | 64b5c4a9bb3e |
children | d5a0698a8354 590caab5d6c7 |
files | Doc/library/select.rst Lib/test/test_epoll.py Misc/NEWS Modules/selectmodule.c |
diffstat | 4 files changed, 36 insertions(+), 1 deletions(-)[+] [-] Doc/library/select.rst 5 Lib/test/test_epoll.py 7 Misc/NEWS 3 Modules/selectmodule.c 22 |
line wrap: on
line diff
--- a/Doc/library/select.rst
+++ b/Doc/library/select.rst
@@ -47,11 +47,14 @@ The module defines the following:
to :const:EPOLL_CLOEXEC
, which causes the epoll descriptor to be closed
automatically when :func:os.execve
is called. See section
:ref:epoll-objects
below for the methods supported by epolling objects.
-
- They also support the :keyword:
with
statement. .. versionchanged:: 3.3 Added the flags parameter. - .. versionchanged:: 3.4
Support for the :keyword:`with` statement was added.[](#l1.14)
--- a/Lib/test/test_epoll.py +++ b/Lib/test/test_epoll.py @@ -87,6 +87,13 @@ class TestEPoll(unittest.TestCase): self.assertRaises(TypeError, select.epoll, ['foo']) self.assertRaises(TypeError, select.epoll, {})
- def test_context_manager(self):
with select.epoll(16) as ep:[](#l2.8)
self.assertGreater(ep.fileno(), 0)[](#l2.9)
self.assertFalse(ep.closed)[](#l2.10)
self.assertTrue(ep.closed)[](#l2.11)
self.assertRaises(ValueError, ep.fileno)[](#l2.12)
+ def test_add(self): server, client = self._connected_pair()
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -167,6 +167,9 @@ Core and Builtins
Library
-------
+- Issue #16488: epoll() objects now support the with
statement. Patch
- Issue #16298: In HTTPResponse.read(), close the socket when there is no Content-Length and the incoming stream is finished. Patch by Eran Rundstein.
--- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -1394,6 +1394,24 @@ Wait for events on the epoll file descri in seconds (as float). -1 makes poll wait indefinitely.\n[](#l4.4) Up to maxevents are returned to the caller."); +static PyObject * +pyepoll_enter(pyEpoll_Object *self, PyObject *args) +{
+} + +static PyObject * +pyepoll_exit(PyObject *self, PyObject *args) +{
+} + static PyMethodDef pyepoll_methods[] = { {"fromfd", (PyCFunction)pyepoll_fromfd, METH_VARARGS | METH_CLASS, pyepoll_fromfd_doc}, @@ -1409,6 +1427,10 @@ static PyMethodDef pyepoll_methods[] = { METH_VARARGS | METH_KEYWORDS, pyepoll_unregister_doc}, {"poll", (PyCFunction)pyepoll_poll, METH_VARARGS | METH_KEYWORDS, pyepoll_poll_doc},