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
8db3027e
Kaydet (Commit)
8db3027e
authored
Eyl 18, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #9895: speed up test_subprocess
üst
81c4d369
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
13 deletions
+32
-13
test_subprocess.py
Lib/test/test_subprocess.py
+32
-13
No files found.
Lib/test/test_subprocess.py
Dosyayı görüntüle @
8db3027e
...
...
@@ -445,21 +445,40 @@ class ProcessTestCase(BaseTestCase):
def
test_no_leaking
(
self
):
# Make sure we leak no resources
if
(
not
hasattr
(
support
,
"is_resource_enabled"
)
or
support
.
is_resource_enabled
(
"subprocess"
)
and
not
mswindows
):
if
not
mswindows
:
max_handles
=
1026
# too much for most UNIX systems
else
:
max_handles
=
65
for
i
in
range
(
max_handles
):
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
"import sys;"
"sys.stdout.write(sys.stdin.read())"
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
data
=
p
.
communicate
(
b
"lime"
)[
0
]
self
.
assertEqual
(
data
,
b
"lime"
)
max_handles
=
2050
# too much for (at least some) Windows setups
handles
=
[]
try
:
for
i
in
range
(
max_handles
):
try
:
handles
.
append
(
os
.
open
(
support
.
TESTFN
,
os
.
O_WRONLY
|
os
.
O_CREAT
))
except
OSError
as
e
:
if
e
.
errno
!=
errno
.
EMFILE
:
raise
break
else
:
self
.
skipTest
(
"failed to reach the file descriptor limit "
"(tried
%
d)"
%
max_handles
)
# Close a couple of them (should be enough for a subprocess)
for
i
in
range
(
10
):
os
.
close
(
handles
.
pop
())
# Loop creating some subprocesses. If one of them leaks some fds,
# the next loop iteration will fail by reaching the max fd limit.
for
i
in
range
(
15
):
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
"import sys;"
"sys.stdout.write(sys.stdin.read())"
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
data
=
p
.
communicate
(
b
"lime"
)[
0
]
self
.
assertEqual
(
data
,
b
"lime"
)
finally
:
for
h
in
handles
:
os
.
close
(
h
)
def
test_list2cmdline
(
self
):
self
.
assertEqual
(
subprocess
.
list2cmdline
([
'a b c'
,
'd'
,
'e'
]),
...
...
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