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
62dba4c2
Kaydet (Commit)
62dba4c2
authored
Eyl 10, 2003
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
select.select() now accepts a sequence (as defined by PySequence_Fast()) for
its first three arguments. Closes RFE #798046 .
üst
fd4fa880
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
23 deletions
+25
-23
libselect.tex
Doc/lib/libselect.tex
+5
-5
NEWS
Misc/NEWS
+2
-0
selectmodule.c
Modules/selectmodule.c
+18
-18
No files found.
Doc/lib/libselect.tex
Dosyayı görüntüle @
62dba4c2
...
@@ -32,12 +32,12 @@ polling objects.
...
@@ -32,12 +32,12 @@ polling objects.
\begin{funcdesc}
{
select
}{
iwtd, owtd, ewtd
\optional
{
, timeout
}}
\begin{funcdesc}
{
select
}{
iwtd, owtd, ewtd
\optional
{
, timeout
}}
This is a straightforward interface to the
\UNIX
{}
\cfunction
{
select()
}
This is a straightforward interface to the
\UNIX
{}
\cfunction
{
select()
}
system call. The first three arguments are
list
s of `waitable
system call. The first three arguments are
sequence
s of `waitable
objects': either integers representing file descriptors or
objects': either integers representing file descriptors or
objects with a parameterless method named
\method
{
fileno()
}
returning
objects with a parameterless method named
\method
{
fileno()
}
returning
such an integer. The three
list
s of waitable objects are for input,
such an integer. The three
sequence
s of waitable objects are for input,
output and `exceptional conditions', respectively. Empty
list
s are
output and `exceptional conditions', respectively. Empty
sequence
s are
allowed, but acceptance of three empty
list
s is platform-dependent.
allowed, but acceptance of three empty
sequence
s is platform-dependent.
(It is known to work on
\UNIX
{}
but not on Windows.) The optional
(It is known to work on
\UNIX
{}
but not on Windows.) The optional
\var
{
timeout
}
argument specifies a time-out as a floating point number
\var
{
timeout
}
argument specifies a time-out as a floating point number
in seconds. When the
\var
{
timeout
}
argument is omitted the function
in seconds. When the
\var
{
timeout
}
argument is omitted the function
...
@@ -49,7 +49,7 @@ subsets of the first three arguments. When the time-out is reached
...
@@ -49,7 +49,7 @@ subsets of the first three arguments. When the time-out is reached
without a file descriptor becoming ready, three empty lists are
without a file descriptor becoming ready, three empty lists are
returned.
returned.
Among the acceptable object types in the
list
s are Python file
Among the acceptable object types in the
sequence
s are Python file
objects (e.g.
\code
{
sys.stdin
}
, or objects returned by
objects (e.g.
\code
{
sys.stdin
}
, or objects returned by
\function
{
open()
}
or
\function
{
os.popen()
}
), socket objects
\function
{
open()
}
or
\function
{
os.popen()
}
), socket objects
returned by
\function
{
socket.socket()
}
.
%
returned by
\function
{
socket.socket()
}
.
%
...
...
Misc/NEWS
Dosyayı görüntüle @
62dba4c2
...
@@ -24,6 +24,8 @@ Core and builtins
...
@@ -24,6 +24,8 @@ Core and builtins
Extension
modules
Extension
modules
-----------------
-----------------
-
select
.
select
()
now
accepts
sequences
for
its
first
three
arguments
.
-
cStringIO
now
supports
the
f
.
closed
attribute
.
-
cStringIO
now
supports
the
f
.
closed
attribute
.
-
The
signal
module
now
exposes
SIGRTMIN
and
SIGRTMAX
(
if
available
).
-
The
signal
module
now
exposes
SIGRTMIN
and
SIGRTMAX
(
if
available
).
...
...
Modules/selectmodule.c
Dosyayı görüntüle @
62dba4c2
...
@@ -75,22 +75,29 @@ reap_obj(pylist fd2obj[FD_SETSIZE + 1])
...
@@ -75,22 +75,29 @@ reap_obj(pylist fd2obj[FD_SETSIZE + 1])
returns a number >= 0
returns a number >= 0
*/
*/
static
int
static
int
list2set
(
PyObject
*
list
,
fd_set
*
set
,
pylist
fd2obj
[
FD_SETSIZE
+
1
])
seq2set
(
PyObject
*
seq
,
fd_set
*
set
,
pylist
fd2obj
[
FD_SETSIZE
+
1
])
{
{
int
i
;
int
i
;
int
max
=
-
1
;
int
max
=
-
1
;
int
index
=
0
;
int
index
=
0
;
int
len
=
PyList_Size
(
list
);
int
len
=
-
1
;
PyObject
*
fast_seq
=
NULL
;
PyObject
*
o
=
NULL
;
PyObject
*
o
=
NULL
;
fd2obj
[
0
].
obj
=
(
PyObject
*
)
0
;
/* set list to zero size */
fd2obj
[
0
].
obj
=
(
PyObject
*
)
0
;
/* set list to zero size */
FD_ZERO
(
set
);
FD_ZERO
(
set
);
fast_seq
=
PySequence_Fast
(
seq
,
"arguments 1-3 must be sequences"
);
if
(
!
fast_seq
)
return
-
1
;
len
=
PySequence_Fast_GET_SIZE
(
fast_seq
);
for
(
i
=
0
;
i
<
len
;
i
++
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
SOCKET
v
;
SOCKET
v
;
/* any intervening fileno() calls could decr this refcnt */
/* any intervening fileno() calls could decr this refcnt */
if
(
!
(
o
=
Py
List_GetItem
(
list
,
i
)))
if
(
!
(
o
=
Py
Sequence_Fast_GET_ITEM
(
fast_seq
,
i
)))
return
-
1
;
return
-
1
;
Py_INCREF
(
o
);
Py_INCREF
(
o
);
...
@@ -121,10 +128,12 @@ list2set(PyObject *list, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
...
@@ -121,10 +128,12 @@ list2set(PyObject *list, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
fd2obj
[
index
].
sentinel
=
0
;
fd2obj
[
index
].
sentinel
=
0
;
fd2obj
[
++
index
].
sentinel
=
-
1
;
fd2obj
[
++
index
].
sentinel
=
-
1
;
}
}
Py_DECREF
(
fast_seq
);
return
max
+
1
;
return
max
+
1
;
finally:
finally:
Py_XDECREF
(
o
);
Py_XDECREF
(
o
);
Py_DECREF
(
fast_seq
);
return
-
1
;
return
-
1
;
}
}
...
@@ -229,15 +238,6 @@ select_select(PyObject *self, PyObject *args)
...
@@ -229,15 +238,6 @@ select_select(PyObject *self, PyObject *args)
tvp
=
&
tv
;
tvp
=
&
tv
;
}
}
/* sanity check first three arguments */
if
(
!
PyList_Check
(
ifdlist
)
||
!
PyList_Check
(
ofdlist
)
||
!
PyList_Check
(
efdlist
))
{
PyErr_SetString
(
PyExc_TypeError
,
"arguments 1-3 must be lists"
);
return
NULL
;
}
#ifdef SELECT_USES_HEAP
#ifdef SELECT_USES_HEAP
/* Allocate memory for the lists */
/* Allocate memory for the lists */
...
@@ -251,17 +251,17 @@ select_select(PyObject *self, PyObject *args)
...
@@ -251,17 +251,17 @@ select_select(PyObject *self, PyObject *args)
return
PyErr_NoMemory
();
return
PyErr_NoMemory
();
}
}
#endif
/* SELECT_USES_HEAP */
#endif
/* SELECT_USES_HEAP */
/* Convert
list
s to fd_sets, and get maximum fd number
/* Convert
sequence
s to fd_sets, and get maximum fd number
* propagates the Python exception set in
list
2set()
* propagates the Python exception set in
seq
2set()
*/
*/
rfd2obj
[
0
].
sentinel
=
-
1
;
rfd2obj
[
0
].
sentinel
=
-
1
;
wfd2obj
[
0
].
sentinel
=
-
1
;
wfd2obj
[
0
].
sentinel
=
-
1
;
efd2obj
[
0
].
sentinel
=
-
1
;
efd2obj
[
0
].
sentinel
=
-
1
;
if
((
imax
=
list
2set
(
ifdlist
,
&
ifdset
,
rfd2obj
))
<
0
)
if
((
imax
=
seq
2set
(
ifdlist
,
&
ifdset
,
rfd2obj
))
<
0
)
goto
finally
;
goto
finally
;
if
((
omax
=
list
2set
(
ofdlist
,
&
ofdset
,
wfd2obj
))
<
0
)
if
((
omax
=
seq
2set
(
ofdlist
,
&
ofdset
,
wfd2obj
))
<
0
)
goto
finally
;
goto
finally
;
if
((
emax
=
list
2set
(
efdlist
,
&
efdset
,
efd2obj
))
<
0
)
if
((
emax
=
seq
2set
(
efdlist
,
&
efdset
,
efd2obj
))
<
0
)
goto
finally
;
goto
finally
;
max
=
imax
;
max
=
imax
;
if
(
omax
>
max
)
max
=
omax
;
if
(
omax
>
max
)
max
=
omax
;
...
@@ -618,7 +618,7 @@ PyDoc_STRVAR(select_doc,
...
@@ -618,7 +618,7 @@ PyDoc_STRVAR(select_doc,
"select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)
\n
\
"select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)
\n
\
\n
\
\n
\
Wait until one or more file descriptors are ready for some kind of I/O.
\n
\
Wait until one or more file descriptors are ready for some kind of I/O.
\n
\
The first three arguments are
list
s of file descriptors to be waited for:
\n
\
The first three arguments are
sequence
s of file descriptors to be waited for:
\n
\
rlist -- wait until ready for reading
\n
\
rlist -- wait until ready for reading
\n
\
wlist -- wait until ready for writing
\n
\
wlist -- wait until ready for writing
\n
\
xlist -- wait for an ``exceptional condition''
\n
\
xlist -- wait for an ``exceptional condition''
\n
\
...
...
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