Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
41eba224
Kaydet (Commit)
41eba224
authored
Mar 30, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23485: select.epoll.poll() is now retried when interrupted by a signal
üst
3c7d6e06
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
23 deletions
+71
-23
select.rst
Doc/library/select.rst
+6
-0
3.5.rst
Doc/whatsnew/3.5.rst
+1
-1
selectors.py
Lib/selectors.py
+2
-4
eintr_tester.py
Lib/test/eintrdata/eintr_tester.py
+11
-0
selectmodule.c
Modules/selectmodule.c
+51
-18
No files found.
Doc/library/select.rst
Dosyayı görüntüle @
41eba224
...
...
@@ -329,6 +329,12 @@ Edge and Level Trigger Polling (epoll) Objects
Wait for events. timeout in seconds (float)
.. versionchanged:: 3.5
The function is now retried with a recomputed timeout when interrupted by
a signal, except if the signal handler raises an exception (see
:pep:`475` for the rationale), instead of raising
:exc:`InterruptedError`.
.. _poll-objects:
...
...
Doc/whatsnew/3.5.rst
Dosyayı görüntüle @
41eba224
...
...
@@ -621,7 +621,7 @@ Changes in the Python API
- :func:`os.open`, :func:`open`
- :func:`os.read`, :func:`os.write`
- :func:`select.select`, :func:`select.poll.poll`
- :func:`select.select`, :func:`select.poll.poll`
, :func:`select.epoll.poll`
- :func:`time.sleep`
* Before Python 3.5, a :class:`datetime.time` object was considered to be false
...
...
Lib/selectors.py
Dosyayı görüntüle @
41eba224
...
...
@@ -423,11 +423,9 @@ if hasattr(select, 'epoll'):
# FD is registered.
max_ev
=
max
(
len
(
self
.
_fd_to_key
),
1
)
fd_event_list
=
self
.
_epoll
.
poll
(
timeout
,
max_ev
)
ready
=
[]
try
:
fd_event_list
=
self
.
_epoll
.
poll
(
timeout
,
max_ev
)
except
InterruptedError
:
return
ready
for
fd
,
event
in
fd_event_list
:
events
=
0
if
event
&
~
select
.
EPOLLIN
:
...
...
Lib/test/eintrdata/eintr_tester.py
Dosyayı görüntüle @
41eba224
...
...
@@ -329,6 +329,17 @@ class SelectEINTRTest(EINTRBaseTest):
dt
=
time
.
monotonic
()
-
t0
self
.
assertGreaterEqual
(
dt
,
self
.
sleep_time
)
@unittest.skipUnless
(
hasattr
(
select
,
'epoll'
),
'need select.epoll'
)
def
test_epoll
(
self
):
poller
=
select
.
epoll
()
self
.
addCleanup
(
poller
.
close
)
t0
=
time
.
monotonic
()
poller
.
poll
(
self
.
sleep_time
)
self
.
stop_alarm
()
dt
=
time
.
monotonic
()
-
t0
self
.
assertGreaterEqual
(
dt
,
self
.
sleep_time
)
def
test_main
():
support
.
run_unittest
(
...
...
Modules/selectmodule.c
Dosyayı görüntüle @
41eba224
...
...
@@ -535,7 +535,7 @@ poll_poll(pollObject *self, PyObject *args)
if
(
timeout_obj
==
NULL
||
timeout_obj
==
Py_None
)
{
timeout
=
-
1
;
ms
=
-
1
;
deadline
=
0
;
deadline
=
0
;
/* initialize to prevent gcc warning */
}
else
{
if
(
_PyTime_FromMillisecondsObject
(
&
timeout
,
timeout_obj
,
...
...
@@ -1465,34 +1465,46 @@ fd is the target file descriptor of the operation.");
static
PyObject
*
pyepoll_poll
(
pyEpoll_Object
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
double
dtimeout
=
-
1
.
;
int
timeout
;
static
char
*
kwlist
[]
=
{
"timeout"
,
"maxevents"
,
NULL
}
;
PyObject
*
timeout_obj
=
NULL
;
int
maxevents
=
-
1
;
int
nfds
,
i
;
PyObject
*
elist
=
NULL
,
*
etuple
=
NULL
;
struct
epoll_event
*
evs
=
NULL
;
static
char
*
kwlist
[]
=
{
"timeout"
,
"maxevents"
,
NULL
}
;
_PyTime_t
timeout
,
ms
,
deadline
;
if
(
self
->
epfd
<
0
)
return
pyepoll_err_closed
();
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|
d
i:poll"
,
kwlist
,
&
dtimeout
,
&
maxevents
))
{
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|
O
i:poll"
,
kwlist
,
&
timeout_obj
,
&
maxevents
))
{
return
NULL
;
}
if
(
dtimeout
<
0
)
{
if
(
timeout_obj
==
NULL
||
timeout_obj
==
Py_None
)
{
timeout
=
-
1
;
}
else
if
(
dtimeout
*
1000
.
0
>
INT_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"timeout is too large"
);
return
NULL
;
ms
=
-
1
;
deadline
=
0
;
/* initialize to prevent gcc warning */
}
else
{
/* epoll_wait() has a resolution of 1 millisecond, round away from zero
to wait *at least* dtimeout seconds. */
timeout
=
(
int
)
ceil
(
dtimeout
*
1000
.
0
);
/* epoll_wait() has a resolution of 1 millisecond, round towards
infinity to wait at least timeout seconds. */
if
(
_PyTime_FromSecondsObject
(
&
timeout
,
timeout_obj
,
_PyTime_ROUND_CEILING
)
<
0
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_TypeError
))
{
PyErr_SetString
(
PyExc_TypeError
,
"timeout must be an integer or None"
);
}
return
NULL
;
}
ms
=
_PyTime_AsMilliseconds
(
timeout
,
_PyTime_ROUND_CEILING
);
if
(
ms
<
INT_MIN
||
ms
>
INT_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"timeout is too large"
);
return
NULL
;
}
deadline
=
_PyTime_GetMonotonicClock
()
+
timeout
;
}
if
(
maxevents
==
-
1
)
{
...
...
@@ -1511,9 +1523,30 @@ pyepoll_poll(pyEpoll_Object *self, PyObject *args, PyObject *kwds)
return
NULL
;
}
Py_BEGIN_ALLOW_THREADS
nfds
=
epoll_wait
(
self
->
epfd
,
evs
,
maxevents
,
timeout
);
Py_END_ALLOW_THREADS
do
{
Py_BEGIN_ALLOW_THREADS
errno
=
0
;
nfds
=
epoll_wait
(
self
->
epfd
,
evs
,
maxevents
,
(
int
)
ms
);
Py_END_ALLOW_THREADS
if
(
errno
!=
EINTR
)
break
;
/* poll() was interrupted by a signal */
if
(
PyErr_CheckSignals
())
goto
error
;
if
(
timeout
>=
0
)
{
timeout
=
deadline
-
_PyTime_GetMonotonicClock
();
if
(
timeout
<
0
)
{
nfds
=
0
;
break
;
}
ms
=
_PyTime_AsMilliseconds
(
timeout
,
_PyTime_ROUND_CEILING
);
/* retry epoll_wait() with the recomputed timeout */
}
}
while
(
1
);
if
(
nfds
<
0
)
{
PyErr_SetFromErrno
(
PyExc_OSError
);
goto
error
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment