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
bca6ae67
Kaydet (Commit)
bca6ae67
authored
Kas 20, 2014
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge 3.4 (asyncio)
üst
8beadd3d
2d99d93d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
21 deletions
+35
-21
base_events.py
Lib/asyncio/base_events.py
+7
-4
unix_events.py
Lib/asyncio/unix_events.py
+3
-2
test_base_events.py
Lib/test/test_asyncio/test_base_events.py
+15
-11
test_unix_events.py
Lib/test/test_asyncio/test_unix_events.py
+10
-4
No files found.
Lib/asyncio/base_events.py
Dosyayı görüntüle @
bca6ae67
...
...
@@ -357,7 +357,8 @@ class BaseEventLoop(events.AbstractEventLoop):
Absolute time corresponds to the event loop's time() method.
"""
if
coroutines
.
iscoroutinefunction
(
callback
):
if
(
coroutines
.
iscoroutine
(
callback
)
or
coroutines
.
iscoroutinefunction
(
callback
)):
raise
TypeError
(
"coroutines cannot be used with call_at()"
)
if
self
.
_debug
:
self
.
_assert_is_current_event_loop
()
...
...
@@ -384,7 +385,8 @@ class BaseEventLoop(events.AbstractEventLoop):
return
handle
def
_call_soon
(
self
,
callback
,
args
,
check_loop
):
if
coroutines
.
iscoroutinefunction
(
callback
):
if
(
coroutines
.
iscoroutine
(
callback
)
or
coroutines
.
iscoroutinefunction
(
callback
)):
raise
TypeError
(
"coroutines cannot be used with call_soon()"
)
if
self
.
_debug
and
check_loop
:
self
.
_assert_is_current_event_loop
()
...
...
@@ -421,8 +423,9 @@ class BaseEventLoop(events.AbstractEventLoop):
return
handle
def
run_in_executor
(
self
,
executor
,
callback
,
*
args
):
if
coroutines
.
iscoroutinefunction
(
callback
):
raise
TypeError
(
"Coroutines cannot be used with run_in_executor()"
)
if
(
coroutines
.
iscoroutine
(
callback
)
or
coroutines
.
iscoroutinefunction
(
callback
)):
raise
TypeError
(
"coroutines cannot be used with run_in_executor()"
)
if
isinstance
(
callback
,
events
.
Handle
):
assert
not
args
assert
not
isinstance
(
callback
,
events
.
TimerHandle
)
...
...
Lib/asyncio/unix_events.py
Dosyayı görüntüle @
bca6ae67
...
...
@@ -67,8 +67,9 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
Raise ValueError if the signal number is invalid or uncatchable.
Raise RuntimeError if there is a problem setting up the handler.
"""
if
coroutines
.
iscoroutinefunction
(
callback
):
raise
TypeError
(
"coroutines cannot be used with call_soon()"
)
if
(
coroutines
.
iscoroutine
(
callback
)
or
coroutines
.
iscoroutinefunction
(
callback
)):
raise
TypeError
(
"coroutines cannot be used with add_signal_handler()"
)
self
.
_check_signal
(
sig
)
try
:
# set_wakeup_fd() raises ValueError if this is not the
...
...
Lib/test/test_asyncio/test_base_events.py
Dosyayı görüntüle @
bca6ae67
...
...
@@ -1107,19 +1107,23 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
def
test_call_coroutine
(
self
):
@asyncio.coroutine
def
coroutine_function
():
def
simple_coroutine
():
pass
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
call_soon
(
coroutine_function
)
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
call_soon_threadsafe
(
coroutine_function
)
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
call_later
(
60
,
coroutine_function
)
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
call_at
(
self
.
loop
.
time
()
+
60
,
coroutine_function
)
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
run_in_executor
(
None
,
coroutine_function
)
coro_func
=
simple_coroutine
coro_obj
=
coro_func
()
self
.
addCleanup
(
coro_obj
.
close
)
for
func
in
(
coro_func
,
coro_obj
):
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
call_soon
(
func
)
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
call_soon_threadsafe
(
func
)
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
call_later
(
60
,
func
)
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
call_at
(
self
.
loop
.
time
()
+
60
,
func
)
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
run_in_executor
(
None
,
func
)
@mock.patch
(
'asyncio.base_events.logger'
)
def
test_log_slow_callbacks
(
self
,
m_logger
):
...
...
Lib/test/test_asyncio/test_unix_events.py
Dosyayı görüntüle @
bca6ae67
...
...
@@ -65,15 +65,21 @@ class SelectorEventLoopSignalTests(test_utils.TestCase):
@mock.patch
(
'asyncio.unix_events.signal'
)
def
test_add_signal_handler_coroutine_error
(
self
,
m_signal
):
m_signal
.
NSIG
=
signal
.
NSIG
@asyncio.coroutine
def
simple_coroutine
():
yield
from
[]
self
.
assertRaises
(
TypeError
,
self
.
loop
.
add_signal_handler
,
signal
.
SIGINT
,
simple_coroutine
)
# callback must not be a coroutine function
coro_func
=
simple_coroutine
coro_obj
=
coro_func
()
self
.
addCleanup
(
coro_obj
.
close
)
for
func
in
(
coro_func
,
coro_obj
):
self
.
assertRaisesRegex
(
TypeError
,
'coroutines cannot be used with add_signal_handler'
,
self
.
loop
.
add_signal_handler
,
signal
.
SIGINT
,
func
)
@mock.patch
(
'asyncio.unix_events.signal'
)
def
test_add_signal_handler
(
self
,
m_signal
):
...
...
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