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
ab27a9fc
Kaydet (Commit)
ab27a9fc
authored
Ock 26, 2014
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
asyncio: Fix race in FastChildWatcher (by its original author, Anthony Baire).
üst
669eeaf9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
20 deletions
+16
-20
unix_events.py
Lib/asyncio/unix_events.py
+16
-20
No files found.
Lib/asyncio/unix_events.py
Dosyayı görüntüle @
ab27a9fc
...
@@ -641,22 +641,16 @@ class FastChildWatcher(BaseChildWatcher):
...
@@ -641,22 +641,16 @@ class FastChildWatcher(BaseChildWatcher):
def
add_child_handler
(
self
,
pid
,
callback
,
*
args
):
def
add_child_handler
(
self
,
pid
,
callback
,
*
args
):
assert
self
.
_forks
,
"Must use the context manager"
assert
self
.
_forks
,
"Must use the context manager"
with
self
.
_lock
:
try
:
returncode
=
self
.
_zombies
.
pop
(
pid
)
except
KeyError
:
# The child is running.
self
.
_callbacks
[
pid
]
=
callback
,
args
return
self
.
_callbacks
[
pid
]
=
callback
,
args
# The child is dead already. We can fire the callback.
callback
(
pid
,
returncode
,
*
args
)
try
:
# Ensure that the child is not already terminated.
# (raise KeyError if still alive)
returncode
=
self
.
_zombies
.
pop
(
pid
)
# Child is dead, therefore we can fire the callback immediately.
# First we remove it from the dict.
# (raise KeyError if .remove_child_handler() was called in-between)
del
self
.
_callbacks
[
pid
]
except
KeyError
:
pass
else
:
callback
(
pid
,
returncode
,
*
args
)
def
remove_child_handler
(
self
,
pid
):
def
remove_child_handler
(
self
,
pid
):
try
:
try
:
...
@@ -681,16 +675,18 @@ class FastChildWatcher(BaseChildWatcher):
...
@@ -681,16 +675,18 @@ class FastChildWatcher(BaseChildWatcher):
returncode
=
self
.
_compute_returncode
(
status
)
returncode
=
self
.
_compute_returncode
(
status
)
try
:
with
self
.
_lock
:
callback
,
args
=
self
.
_callbacks
.
pop
(
pid
)
try
:
except
KeyError
:
callback
,
args
=
self
.
_callbacks
.
pop
(
pid
)
# unknown child
except
KeyError
:
with
self
.
_lock
:
# unknown child
if
self
.
_forks
:
if
self
.
_forks
:
# It may not be registered yet.
# It may not be registered yet.
self
.
_zombies
[
pid
]
=
returncode
self
.
_zombies
[
pid
]
=
returncode
continue
continue
callback
=
None
if
callback
is
None
:
logger
.
warning
(
logger
.
warning
(
"Caught subprocess termination from unknown pid: "
"Caught subprocess termination from unknown pid: "
"
%
d ->
%
d"
,
pid
,
returncode
)
"
%
d ->
%
d"
,
pid
,
returncode
)
...
...
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