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
504f5c36
Kaydet (Commit)
504f5c36
authored
Haz 20, 2014
tarafından
Charles-François Natali
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #21491: socketserver: Fix a race condition in child processes reaping.
üst
af9eb962
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
26 deletions
+32
-26
socketserver.py
Lib/socketserver.py
+30
-26
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/socketserver.py
Dosyayı görüntüle @
504f5c36
...
...
@@ -523,35 +523,39 @@ class ForkingMixIn:
def
collect_children
(
self
):
"""Internal routine to wait for children that have exited."""
if
self
.
active_children
is
None
:
return
if
self
.
active_children
is
None
:
return
# If we're above the max number of children, wait and reap them until
# we go back below threshold. Note that we use waitpid(-1) below to be
# able to collect children in size(<defunct children>) syscalls instead
# of size(<children>): the downside is that this might reap children
# which we didn't spawn, which is why we only resort to this when we're
# above max_children.
while
len
(
self
.
active_children
)
>=
self
.
max_children
:
# XXX: This will wait for any child process, not just ones
# spawned by this library. This could confuse other
# libraries that expect to be able to wait for their own
# children.
try
:
pid
,
status
=
os
.
waitpid
(
0
,
0
)
pid
,
_
=
os
.
waitpid
(
-
1
,
0
)
self
.
active_children
.
discard
(
pid
)
except
InterruptedError
:
pass
except
ChildProcessError
:
# we don't have any children, we're done
self
.
active_children
.
clear
()
except
OSError
:
pid
=
None
if
pid
not
in
self
.
active_children
:
continue
self
.
active_children
.
remove
(
pid
)
# XXX: This loop runs more system calls than it ought
# to. There should be a way to put the active_children into a
# process group and then use os.waitpid(-pgid) to wait for any
# of that set, but I couldn't find a way to allocate pgids
# that couldn't collide.
for
child
in
self
.
active_children
:
break
# Now reap all defunct children.
for
pid
in
self
.
active_children
.
copy
():
try
:
pid
,
status
=
os
.
waitpid
(
child
,
os
.
WNOHANG
)
pid
,
_
=
os
.
waitpid
(
pid
,
os
.
WNOHANG
)
# if the child hasn't exited yet, pid will be 0 and ignored by
# discard() below
self
.
active_children
.
discard
(
pid
)
except
ChildProcessError
:
# someone else reaped it
self
.
active_children
.
discard
(
pid
)
except
OSError
:
pid
=
None
if
not
pid
:
continue
try
:
self
.
active_children
.
remove
(
pid
)
except
ValueError
as
e
:
raise
ValueError
(
'
%
s. x=
%
d and list=
%
r'
%
(
e
.
message
,
pid
,
self
.
active_children
))
pass
def
handle_timeout
(
self
):
"""Wait for zombies after self.timeout seconds of inactivity.
...
...
@@ -573,8 +577,8 @@ class ForkingMixIn:
if
pid
:
# Parent process
if
self
.
active_children
is
None
:
self
.
active_children
=
[]
self
.
active_children
.
a
ppen
d
(
pid
)
self
.
active_children
=
set
()
self
.
active_children
.
a
d
d
(
pid
)
self
.
close_request
(
request
)
return
else
:
...
...
Misc/NEWS
Dosyayı görüntüle @
504f5c36
...
...
@@ -27,6 +27,8 @@ Core and Builtins
Library
-------
- Issue #21491: socketserver: Fix a race condition in child processes reaping.
- Issue #21722: The distutils "upload" command now exits with a non-zero
return code when uploading fails. Patch by Martin Dengler.
...
...
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