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
67ba547c
Kaydet (Commit)
67ba547c
authored
Ock 05, 2019
tarafından
Vladimir Matveev
Kaydeden (comit)
Andrew Svetlov
Ock 05, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-23057: Use 'raise' to emulate ctrl-c in proactor tests (#11274)
üst
31ec52a9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
76 deletions
+24
-76
windows_events.py
Lib/asyncio/windows_events.py
+5
-0
test_ctrl_c_in_proactor_loop_helper.py
Lib/test/test_asyncio/test_ctrl_c_in_proactor_loop_helper.py
+0
-63
test_windows_events.py
Lib/test/test_asyncio/test_windows_events.py
+19
-13
No files found.
Lib/asyncio/windows_events.py
Dosyayı görüntüle @
67ba547c
...
...
@@ -315,7 +315,12 @@ class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
super
()
.
run_forever
()
finally
:
if
self
.
_self_reading_future
is
not
None
:
ov
=
self
.
_self_reading_future
.
_ov
self
.
_self_reading_future
.
cancel
()
# self_reading_future was just cancelled so it will never be signalled
# Unregister it otherwise IocpProactor.close will wait for it forever
if
ov
is
not
None
:
self
.
_proactor
.
_unregister
(
ov
)
self
.
_self_reading_future
=
None
async
def
create_pipe_connection
(
self
,
protocol_factory
,
address
):
...
...
Lib/test/test_asyncio/test_ctrl_c_in_proactor_loop_helper.py
deleted
100644 → 0
Dosyayı görüntüle @
31ec52a9
import
sys
def
do_in_child_process
():
import
asyncio
asyncio
.
set_event_loop_policy
(
asyncio
.
WindowsProactorEventLoopPolicy
())
l
=
asyncio
.
get_event_loop
()
def
step
(
n
):
try
:
print
(
n
)
sys
.
stdout
.
flush
()
l
.
run_forever
()
sys
.
exit
(
100
)
except
KeyboardInterrupt
:
# ok
pass
except
:
# error - use default exit code
sys
.
exit
(
200
)
step
(
1
)
step
(
2
)
sys
.
exit
(
255
)
def
do_in_main_process
():
import
os
import
signal
import
subprocess
import
time
from
test.support.script_helper
import
spawn_python
ok
=
False
def
step
(
p
,
expected
):
s
=
p
.
stdout
.
readline
()
if
s
!=
expected
:
raise
Exception
(
f
"Unexpected line: got {s}, expected '{expected}'"
)
# ensure that child process gets to run_forever
time
.
sleep
(
0.5
)
os
.
kill
(
p
.
pid
,
signal
.
CTRL_C_EVENT
)
with
spawn_python
(
__file__
,
"--child"
)
as
p
:
try
:
# ignore ctrl-c in current process
signal
.
signal
(
signal
.
SIGINT
,
signal
.
SIG_IGN
)
step
(
p
,
b
"1
\r\n
"
)
step
(
p
,
b
"2
\r\n
"
)
exit_code
=
p
.
wait
(
timeout
=
5
)
ok
=
exit_code
=
255
except
Exception
as
e
:
sys
.
stderr
.
write
(
repr
(
e
))
p
.
kill
()
sys
.
exit
(
255
if
ok
else
1
)
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
==
1
:
do_in_main_process
()
else
:
do_in_child_process
()
Lib/test/test_asyncio/test_windows_events.py
Dosyayı görüntüle @
67ba547c
...
...
@@ -4,6 +4,7 @@ import socket
import
sys
import
subprocess
import
time
import
threading
import
unittest
from
unittest
import
mock
...
...
@@ -11,6 +12,7 @@ if sys.platform != 'win32':
raise
unittest
.
SkipTest
(
'Windows only'
)
import
_overlapped
import
_testcapi
import
_winapi
import
asyncio
...
...
@@ -38,20 +40,24 @@ class UpperProto(asyncio.Protocol):
class
ProactorLoopCtrlC
(
test_utils
.
TestCase
):
def
test_ctrl_c
(
self
):
from
.test_ctrl_c_in_proactor_loop_helper
import
__file__
as
f
# ctrl-c will be sent to all processes that share the same console
# in order to isolate the effect of raising ctrl-c we'll create
# a process with a new console
flags
=
subprocess
.
CREATE_NEW_CONSOLE
with
spawn_python
(
f
,
creationflags
=
flags
)
as
p
:
try
:
exit_code
=
p
.
wait
(
timeout
=
5
)
self
.
assertEqual
(
exit_code
,
255
)
except
:
p
.
kill
()
raise
def
SIGINT_after_delay
():
time
.
sleep
(
1
)
_testcapi
.
raise_signal
(
signal
.
SIGINT
)
asyncio
.
set_event_loop_policy
(
asyncio
.
WindowsProactorEventLoopPolicy
())
l
=
asyncio
.
get_event_loop
()
try
:
t
=
threading
.
Thread
(
target
=
SIGINT_after_delay
)
t
.
start
()
l
.
run_forever
()
self
.
fail
(
"should not fall through 'run_forever'"
)
except
KeyboardInterrupt
:
pass
finally
:
l
.
close
()
class
ProactorTests
(
test_utils
.
TestCase
):
...
...
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