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
2e2c05c2
Kaydet (Commit)
2e2c05c2
authored
Nis 15, 2014
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
asyncio: Add gi_{frame,running,code} properties to CoroWrapper (upstream #163).
üst
d1229065
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
tasks.py
Lib/asyncio/tasks.py
+12
-0
test_tasks.py
Lib/test/test_asyncio/test_tasks.py
+47
-0
No files found.
Lib/asyncio/tasks.py
Dosyayı görüntüle @
2e2c05c2
...
...
@@ -63,6 +63,18 @@ class CoroWrapper:
def
close
(
self
):
return
self
.
gen
.
close
()
@property
def
gi_frame
(
self
):
return
self
.
gen
.
gi_frame
@property
def
gi_running
(
self
):
return
self
.
gen
.
gi_running
@property
def
gi_code
(
self
):
return
self
.
gen
.
gi_code
def
__del__
(
self
):
frame
=
self
.
gen
.
gi_frame
if
frame
is
not
None
and
frame
.
f_lasti
==
-
1
:
...
...
Lib/test/test_asyncio/test_tasks.py
Dosyayı görüntüle @
2e2c05c2
...
...
@@ -2,6 +2,7 @@
import
gc
import
os.path
import
types
import
unittest
from
test.script_helper
import
assert_python_ok
...
...
@@ -1386,6 +1387,52 @@ class TaskTests(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
self
.
loop
.
run_until_complete
,
asyncio
.
wait
([],
loop
=
self
.
loop
))
def
test_corowrapper_mocks_generator
(
self
):
def
check
():
# A function that asserts various things.
# Called twice, with different debug flag values.
@asyncio.coroutine
def
coro
():
# The actual coroutine.
self
.
assertTrue
(
gen
.
gi_running
)
yield
from
fut
# A completed Future used to run the coroutine.
fut
=
asyncio
.
Future
(
loop
=
self
.
loop
)
fut
.
set_result
(
None
)
# Call the coroutine.
gen
=
coro
()
# Check some properties.
self
.
assertTrue
(
asyncio
.
iscoroutine
(
gen
))
self
.
assertIsInstance
(
gen
.
gi_frame
,
types
.
FrameType
)
self
.
assertFalse
(
gen
.
gi_running
)
self
.
assertIsInstance
(
gen
.
gi_code
,
types
.
CodeType
)
# Run it.
self
.
loop
.
run_until_complete
(
gen
)
# The frame should have changed.
self
.
assertIsNone
(
gen
.
gi_frame
)
# Save debug flag.
old_debug
=
asyncio
.
tasks
.
_DEBUG
try
:
# Test with debug flag cleared.
asyncio
.
tasks
.
_DEBUG
=
False
check
()
# Test with debug flag set.
asyncio
.
tasks
.
_DEBUG
=
True
check
()
finally
:
# Restore original debug flag.
asyncio
.
tasks
.
_DEBUG
=
old_debug
def
test_yield_from_corowrapper
(
self
):
old_debug
=
asyncio
.
tasks
.
_DEBUG
asyncio
.
tasks
.
_DEBUG
=
True
...
...
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