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
94ba146d
Kaydet (Commit)
94ba146d
authored
Nis 27, 2014
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
asyncio: Add __weakref__ slots to Handle and CoroWrapper. Upstream issue #166.
üst
83c1ddda
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
2 deletions
+16
-2
events.py
Lib/asyncio/events.py
+1
-1
tasks.py
Lib/asyncio/tasks.py
+1
-1
test_events.py
Lib/test/test_asyncio/test_events.py
+6
-0
test_tasks.py
Lib/test/test_asyncio/test_tasks.py
+8
-0
No files found.
Lib/asyncio/events.py
Dosyayı görüntüle @
94ba146d
...
...
@@ -16,7 +16,7 @@ import socket
class
Handle
:
"""Object returned by callback registration methods."""
__slots__
=
[
'_callback'
,
'_args'
,
'_cancelled'
,
'_loop'
]
__slots__
=
[
'_callback'
,
'_args'
,
'_cancelled'
,
'_loop'
,
'__weakref__'
]
def
__init__
(
self
,
callback
,
args
,
loop
):
assert
not
isinstance
(
callback
,
Handle
),
'A Handle is not a callback'
...
...
Lib/asyncio/tasks.py
Dosyayı görüntüle @
94ba146d
...
...
@@ -36,7 +36,7 @@ _DEBUG = (not sys.flags.ignore_environment
class
CoroWrapper
:
# Wrapper for coroutine in _DEBUG mode.
__slots__
=
[
'gen'
,
'func'
,
'__name__'
,
'__doc__'
]
__slots__
=
[
'gen'
,
'func'
,
'__name__'
,
'__doc__'
,
'__weakref__'
]
def
__init__
(
self
,
gen
,
func
):
assert
inspect
.
isgenerator
(
gen
),
gen
...
...
Lib/test/test_asyncio/test_events.py
Dosyayı görüntüle @
94ba146d
...
...
@@ -21,6 +21,7 @@ import time
import
errno
import
unittest
from
unittest
import
mock
import
weakref
from
test
import
support
# find_unused_port, IPV6_ENABLED, TEST_HOME_DIR
...
...
@@ -1786,6 +1787,11 @@ class HandleTests(unittest.TestCase):
'handle'
:
h
})
def
test_handle_weakref
(
self
):
wd
=
weakref
.
WeakValueDictionary
()
h
=
asyncio
.
Handle
(
lambda
:
None
,
(),
object
())
wd
[
'h'
]
=
h
# Would fail without __weakref__ slot.
class
TimerTests
(
unittest
.
TestCase
):
...
...
Lib/test/test_asyncio/test_tasks.py
Dosyayı görüntüle @
94ba146d
...
...
@@ -4,6 +4,7 @@ import gc
import
os.path
import
types
import
unittest
import
weakref
from
test.script_helper
import
assert_python_ok
import
asyncio
...
...
@@ -1475,6 +1476,13 @@ class TaskTests(unittest.TestCase):
self
.
assertEqual
(
call
((
1
,
2
)),
(
1
,
2
))
self
.
assertEqual
(
call
(
'spam'
),
'spam'
)
def
test_corowrapper_weakref
(
self
):
wd
=
weakref
.
WeakValueDictionary
()
def
foo
():
yield
from
[]
cw
=
asyncio
.
tasks
.
CoroWrapper
(
foo
(),
foo
)
wd
[
'cw'
]
=
cw
# Would fail without __weakref__ slot.
cw
.
gen
=
None
# Suppress warning from __del__.
class
GatherTestsBase
:
...
...
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