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
d625a181
Kaydet (Commit)
d625a181
authored
Ara 11, 2014
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge 3.4 (asyncio)
üst
eb1a995a
1e40f108
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
unix_events.py
Lib/asyncio/unix_events.py
+22
-0
test_subprocess.py
Lib/test/test_asyncio/test_subprocess.py
+21
-0
No files found.
Lib/asyncio/unix_events.py
Dosyayı görüntüle @
d625a181
...
@@ -547,6 +547,22 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
...
@@ -547,6 +547,22 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
self
.
_loop
=
None
self
.
_loop
=
None
if
hasattr
(
os
,
'set_inheritable'
):
# Python 3.4 and newer
_set_inheritable
=
os
.
set_inheritable
else
:
import
fcntl
def
_set_inheritable
(
fd
,
inheritable
):
cloexec_flag
=
getattr
(
fcntl
,
'FD_CLOEXEC'
,
1
)
old
=
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFD
)
if
not
inheritable
:
fcntl
.
fcntl
(
fd
,
fcntl
.
F_SETFD
,
old
|
cloexec_flag
)
else
:
fcntl
.
fcntl
(
fd
,
fcntl
.
F_SETFD
,
old
&
~
cloexec_flag
)
class
_UnixSubprocessTransport
(
base_subprocess
.
BaseSubprocessTransport
):
class
_UnixSubprocessTransport
(
base_subprocess
.
BaseSubprocessTransport
):
def
_start
(
self
,
args
,
shell
,
stdin
,
stdout
,
stderr
,
bufsize
,
**
kwargs
):
def
_start
(
self
,
args
,
shell
,
stdin
,
stdout
,
stderr
,
bufsize
,
**
kwargs
):
...
@@ -558,6 +574,12 @@ class _UnixSubprocessTransport(base_subprocess.BaseSubprocessTransport):
...
@@ -558,6 +574,12 @@ class _UnixSubprocessTransport(base_subprocess.BaseSubprocessTransport):
# other end). Notably this is needed on AIX, and works
# other end). Notably this is needed on AIX, and works
# just fine on other platforms.
# just fine on other platforms.
stdin
,
stdin_w
=
self
.
_loop
.
_socketpair
()
stdin
,
stdin_w
=
self
.
_loop
.
_socketpair
()
# Mark the write end of the stdin pipe as non-inheritable,
# needed by close_fds=False on Python 3.3 and older
# (Python 3.4 implements the PEP 446, socketpair returns
# non-inheritable sockets)
_set_inheritable
(
stdin_w
.
fileno
(),
False
)
self
.
_proc
=
subprocess
.
Popen
(
self
.
_proc
=
subprocess
.
Popen
(
args
,
shell
=
shell
,
stdin
=
stdin
,
stdout
=
stdout
,
stderr
=
stderr
,
args
,
shell
=
shell
,
stdin
=
stdin
,
stdout
=
stdout
,
stderr
=
stderr
,
universal_newlines
=
False
,
bufsize
=
bufsize
,
**
kwargs
)
universal_newlines
=
False
,
bufsize
=
bufsize
,
**
kwargs
)
...
...
Lib/test/test_asyncio/test_subprocess.py
Dosyayı görüntüle @
d625a181
...
@@ -198,6 +198,27 @@ class SubprocessMixin:
...
@@ -198,6 +198,27 @@ class SubprocessMixin:
self
.
assertTrue
(
transport
.
pause_reading
.
called
)
self
.
assertTrue
(
transport
.
pause_reading
.
called
)
self
.
assertTrue
(
transport
.
resume_reading
.
called
)
self
.
assertTrue
(
transport
.
resume_reading
.
called
)
def
test_stdin_not_inheritable
(
self
):
# Tulip issue #209: stdin must not be inheritable, otherwise
# the Process.communicate() hangs
@asyncio.coroutine
def
len_message
(
message
):
code
=
'import sys; data = sys.stdin.read(); print(len(data))'
proc
=
yield
from
asyncio
.
create_subprocess_exec
(
sys
.
executable
,
'-c'
,
code
,
stdin
=
asyncio
.
subprocess
.
PIPE
,
stdout
=
asyncio
.
subprocess
.
PIPE
,
stderr
=
asyncio
.
subprocess
.
PIPE
,
close_fds
=
False
,
loop
=
self
.
loop
)
stdout
,
stderr
=
yield
from
proc
.
communicate
(
message
)
exitcode
=
yield
from
proc
.
wait
()
return
(
stdout
,
exitcode
)
output
,
exitcode
=
self
.
loop
.
run_until_complete
(
len_message
(
b
'abc'
))
self
.
assertEqual
(
output
.
rstrip
(),
b
'3'
)
self
.
assertEqual
(
exitcode
,
0
)
if
sys
.
platform
!=
'win32'
:
if
sys
.
platform
!=
'win32'
:
# Unix
# 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