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
4163cc0d
Kaydet (Commit)
4163cc0d
authored
Şub 10, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge 3.4 (asyncio)
üst
4bdcfce5
8e36812e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletion
+61
-1
base_subprocess.py
Lib/asyncio/base_subprocess.py
+6
-1
test_subprocess.py
Lib/test/test_asyncio/test_subprocess.py
+55
-0
No files found.
Lib/asyncio/base_subprocess.py
Dosyayı görüntüle @
4163cc0d
...
...
@@ -93,7 +93,12 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
continue
proto
.
pipe
.
close
()
if
self
.
_proc
is
not
None
and
self
.
_returncode
is
None
:
if
(
self
.
_proc
is
not
None
# the child process finished?
and
self
.
_returncode
is
None
# the child process finished but the transport was not notified yet?
and
self
.
_proc
.
poll
()
is
None
):
if
self
.
_loop
.
get_debug
():
logger
.
warning
(
'Close running child process: kill
%
r'
,
self
)
...
...
Lib/test/test_asyncio/test_subprocess.py
Dosyayı görüntüle @
4163cc0d
...
...
@@ -349,6 +349,61 @@ class SubprocessMixin:
self
.
loop
.
run_until_complete
(
cancel_make_transport
())
test_utils
.
run_briefly
(
self
.
loop
)
def
test_close_kill_running
(
self
):
@asyncio.coroutine
def
kill_running
():
create
=
self
.
loop
.
subprocess_exec
(
asyncio
.
SubprocessProtocol
,
*
PROGRAM_BLOCKED
)
transport
,
protocol
=
yield
from
create
proc
=
transport
.
get_extra_info
(
'subprocess'
)
proc
.
kill
=
mock
.
Mock
()
returncode
=
transport
.
get_returncode
()
transport
.
close
()
return
(
returncode
,
proc
.
kill
.
called
)
# Ignore "Close running child process: kill ..." log
with
test_utils
.
disable_logger
():
returncode
,
killed
=
self
.
loop
.
run_until_complete
(
kill_running
())
self
.
assertIsNone
(
returncode
)
# transport.close() must kill the process if it is still running
self
.
assertTrue
(
killed
)
test_utils
.
run_briefly
(
self
.
loop
)
def
test_close_dont_kill_finished
(
self
):
@asyncio.coroutine
def
kill_running
():
create
=
self
.
loop
.
subprocess_exec
(
asyncio
.
SubprocessProtocol
,
*
PROGRAM_BLOCKED
)
transport
,
protocol
=
yield
from
create
proc
=
transport
.
get_extra_info
(
'subprocess'
)
# kill the process (but asyncio is not notified immediatly)
proc
.
kill
()
proc
.
wait
()
proc
.
kill
=
mock
.
Mock
()
proc_returncode
=
proc
.
poll
()
transport_returncode
=
transport
.
get_returncode
()
transport
.
close
()
return
(
proc_returncode
,
transport_returncode
,
proc
.
kill
.
called
)
# Ignore "Unknown child process pid ..." log of SafeChildWatcher,
# emitted because the test already consumes the exit status:
# proc.wait()
with
test_utils
.
disable_logger
():
result
=
self
.
loop
.
run_until_complete
(
kill_running
())
test_utils
.
run_briefly
(
self
.
loop
)
proc_returncode
,
transport_return_code
,
killed
=
result
self
.
assertIsNotNone
(
proc_returncode
)
self
.
assertIsNone
(
transport_return_code
)
# transport.close() must not kill the process if it finished, even if
# the transport was not notified yet
self
.
assertFalse
(
killed
)
if
sys
.
platform
!=
'win32'
:
# Unix
...
...
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