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
dc62b7e2
Kaydet (Commit)
dc62b7e2
authored
Şub 09, 2014
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
asyncio: Tulip issue 112: Inline make_handle() into Handle constructor
üst
136fea25
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
9 additions
and
14 deletions
+9
-14
base_events.py
Lib/asyncio/base_events.py
+1
-1
events.py
Lib/asyncio/events.py
+1
-6
selector_events.py
Lib/asyncio/selector_events.py
+2
-2
test_utils.py
Lib/asyncio/test_utils.py
+2
-2
unix_events.py
Lib/asyncio/unix_events.py
+1
-1
test_events.py
Lib/test/test_asyncio/test_events.py
+2
-2
No files found.
Lib/asyncio/base_events.py
Dosyayı görüntüle @
dc62b7e2
...
@@ -240,7 +240,7 @@ class BaseEventLoop(events.AbstractEventLoop):
...
@@ -240,7 +240,7 @@ class BaseEventLoop(events.AbstractEventLoop):
Any positional arguments after the callback will be passed to
Any positional arguments after the callback will be passed to
the callback when it is called.
the callback when it is called.
"""
"""
handle
=
events
.
make_h
andle
(
callback
,
args
)
handle
=
events
.
H
andle
(
callback
,
args
)
self
.
_ready
.
append
(
handle
)
self
.
_ready
.
append
(
handle
)
return
handle
return
handle
...
...
Lib/asyncio/events.py
Dosyayı görüntüle @
dc62b7e2
...
@@ -20,6 +20,7 @@ class Handle:
...
@@ -20,6 +20,7 @@ class Handle:
"""Object returned by callback registration methods."""
"""Object returned by callback registration methods."""
def
__init__
(
self
,
callback
,
args
):
def
__init__
(
self
,
callback
,
args
):
assert
not
isinstance
(
callback
,
Handle
),
'A Handle is not a callback'
self
.
_callback
=
callback
self
.
_callback
=
callback
self
.
_args
=
args
self
.
_args
=
args
self
.
_cancelled
=
False
self
.
_cancelled
=
False
...
@@ -42,12 +43,6 @@ class Handle:
...
@@ -42,12 +43,6 @@ class Handle:
self
=
None
# Needed to break cycles when an exception occurs.
self
=
None
# Needed to break cycles when an exception occurs.
def
make_handle
(
callback
,
args
):
# TODO: Inline this? Or make it a private EventLoop method?
assert
not
isinstance
(
callback
,
Handle
),
'A Handle is not a callback'
return
Handle
(
callback
,
args
)
class
TimerHandle
(
Handle
):
class
TimerHandle
(
Handle
):
"""Object returned by timed callback registration methods."""
"""Object returned by timed callback registration methods."""
...
...
Lib/asyncio/selector_events.py
Dosyayı görüntüle @
dc62b7e2
...
@@ -132,7 +132,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
...
@@ -132,7 +132,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
def
add_reader
(
self
,
fd
,
callback
,
*
args
):
def
add_reader
(
self
,
fd
,
callback
,
*
args
):
"""Add a reader callback."""
"""Add a reader callback."""
handle
=
events
.
make_h
andle
(
callback
,
args
)
handle
=
events
.
H
andle
(
callback
,
args
)
try
:
try
:
key
=
self
.
_selector
.
get_key
(
fd
)
key
=
self
.
_selector
.
get_key
(
fd
)
except
KeyError
:
except
KeyError
:
...
@@ -167,7 +167,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
...
@@ -167,7 +167,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
def
add_writer
(
self
,
fd
,
callback
,
*
args
):
def
add_writer
(
self
,
fd
,
callback
,
*
args
):
"""Add a writer callback.."""
"""Add a writer callback.."""
handle
=
events
.
make_h
andle
(
callback
,
args
)
handle
=
events
.
H
andle
(
callback
,
args
)
try
:
try
:
key
=
self
.
_selector
.
get_key
(
fd
)
key
=
self
.
_selector
.
get_key
(
fd
)
except
KeyError
:
except
KeyError
:
...
...
Lib/asyncio/test_utils.py
Dosyayı görüntüle @
dc62b7e2
...
@@ -216,7 +216,7 @@ class TestLoop(base_events.BaseEventLoop):
...
@@ -216,7 +216,7 @@ class TestLoop(base_events.BaseEventLoop):
raise
AssertionError
(
"Time generator is not finished"
)
raise
AssertionError
(
"Time generator is not finished"
)
def
add_reader
(
self
,
fd
,
callback
,
*
args
):
def
add_reader
(
self
,
fd
,
callback
,
*
args
):
self
.
readers
[
fd
]
=
events
.
make_h
andle
(
callback
,
args
)
self
.
readers
[
fd
]
=
events
.
H
andle
(
callback
,
args
)
def
remove_reader
(
self
,
fd
):
def
remove_reader
(
self
,
fd
):
self
.
remove_reader_count
[
fd
]
+=
1
self
.
remove_reader_count
[
fd
]
+=
1
...
@@ -235,7 +235,7 @@ class TestLoop(base_events.BaseEventLoop):
...
@@ -235,7 +235,7 @@ class TestLoop(base_events.BaseEventLoop):
handle
.
_args
,
args
)
handle
.
_args
,
args
)
def
add_writer
(
self
,
fd
,
callback
,
*
args
):
def
add_writer
(
self
,
fd
,
callback
,
*
args
):
self
.
writers
[
fd
]
=
events
.
make_h
andle
(
callback
,
args
)
self
.
writers
[
fd
]
=
events
.
H
andle
(
callback
,
args
)
def
remove_writer
(
self
,
fd
):
def
remove_writer
(
self
,
fd
):
self
.
remove_writer_count
[
fd
]
+=
1
self
.
remove_writer_count
[
fd
]
+=
1
...
...
Lib/asyncio/unix_events.py
Dosyayı görüntüle @
dc62b7e2
...
@@ -64,7 +64,7 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
...
@@ -64,7 +64,7 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
except
ValueError
as
exc
:
except
ValueError
as
exc
:
raise
RuntimeError
(
str
(
exc
))
raise
RuntimeError
(
str
(
exc
))
handle
=
events
.
make_h
andle
(
callback
,
args
)
handle
=
events
.
H
andle
(
callback
,
args
)
self
.
_signal_handlers
[
sig
]
=
handle
self
.
_signal_handlers
[
sig
]
=
handle
try
:
try
:
...
...
Lib/test/test_asyncio/test_events.py
Dosyayı görüntüle @
dc62b7e2
...
@@ -1660,12 +1660,12 @@ class HandleTests(unittest.TestCase):
...
@@ -1660,12 +1660,12 @@ class HandleTests(unittest.TestCase):
'<function HandleTests.test_handle.<locals>.callback'
))
'<function HandleTests.test_handle.<locals>.callback'
))
self
.
assertTrue
(
r
.
endswith
(
'())<cancelled>'
),
r
)
self
.
assertTrue
(
r
.
endswith
(
'())<cancelled>'
),
r
)
def
test_
make_
handle
(
self
):
def
test_handle
(
self
):
def
callback
(
*
args
):
def
callback
(
*
args
):
return
args
return
args
h1
=
asyncio
.
Handle
(
callback
,
())
h1
=
asyncio
.
Handle
(
callback
,
())
self
.
assertRaises
(
self
.
assertRaises
(
AssertionError
,
asyncio
.
events
.
make_h
andle
,
h1
,
())
AssertionError
,
asyncio
.
H
andle
,
h1
,
())
@unittest.mock.patch
(
'asyncio.events.logger'
)
@unittest.mock.patch
(
'asyncio.events.logger'
)
def
test_callback_with_exception
(
self
,
log
):
def
test_callback_with_exception
(
self
,
log
):
...
...
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