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
df38a80a
Kaydet (Commit)
df38a80a
authored
Kas 22, 2013
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge
üst
224b2612
7a465647
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
3 deletions
+47
-3
asyncio.rst
Doc/library/asyncio.rst
+20
-0
concurrency.rst
Doc/library/concurrency.rst
+1
-0
futures.py
Lib/asyncio/futures.py
+8
-3
test_futures.py
Lib/test/test_asyncio/test_futures.py
+18
-0
No files found.
Doc/library/asyncio.rst
0 → 100644
Dosyayı görüntüle @
df38a80a
:mod:`asyncio` -- Asynchronous I/O, event loop, coroutines and tasks
====================================================================
.. module:: asyncio
:synopsis: Asynchronous I/O, event loop, coroutines and tasks.
.. versionadded:: 3.4
Introduction
------------
This package includes a pluggable event loop, transport and protocol
abstractions similar to those in Twisted, and a higher-level scheduler
for coroutines and tasks based on ``yield from`` (:PEP:`380`).
Full documentation is not yet ready; we hope to have it written
before Python 3.4 leaves beta. Until then, the best reference is
:PEP:`3156`. For a motivational primer on transports and protocols,
see :PEP:`3153`.
Doc/library/concurrency.rst
Dosyayı görüntüle @
df38a80a
...
...
@@ -22,6 +22,7 @@ multitasking). Here's an overview:
queue.rst
select.rst
selectors.rst
asyncio.rst
The following are support modules for some of the above services:
...
...
Lib/asyncio/futures.py
Dosyayı görüntüle @
df38a80a
...
...
@@ -301,6 +301,8 @@ class Future:
The other Future may be a concurrent.futures.Future.
"""
assert
other
.
done
()
if
self
.
cancelled
():
return
assert
not
self
.
done
()
if
other
.
cancelled
():
self
.
cancel
()
...
...
@@ -324,14 +326,17 @@ def wrap_future(fut, *, loop=None):
"""Wrap concurrent.futures.Future object."""
if
isinstance
(
fut
,
Future
):
return
fut
assert
isinstance
(
fut
,
concurrent
.
futures
.
Future
),
\
'concurrent.futures.Future is expected, got {!r}'
.
format
(
fut
)
if
loop
is
None
:
loop
=
events
.
get_event_loop
()
new_future
=
Future
(
loop
=
loop
)
def
_check_cancel_other
(
f
):
if
f
.
cancelled
():
fut
.
cancel
()
new_future
.
add_done_callback
(
_check_cancel_other
)
fut
.
add_done_callback
(
lambda
future
:
loop
.
call_soon_threadsafe
(
new_future
.
_copy_state
,
fut
))
...
...
Lib/test/test_asyncio/test_futures.py
Dosyayı görüntüle @
df38a80a
...
...
@@ -241,6 +241,24 @@ class FutureTests(unittest.TestCase):
f2
=
futures
.
wrap_future
(
f1
)
self
.
assertIs
(
m_events
.
get_event_loop
.
return_value
,
f2
.
_loop
)
def
test_wrap_future_cancel
(
self
):
f1
=
concurrent
.
futures
.
Future
()
f2
=
futures
.
wrap_future
(
f1
,
loop
=
self
.
loop
)
f2
.
cancel
()
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertTrue
(
f1
.
cancelled
())
self
.
assertTrue
(
f2
.
cancelled
())
def
test_wrap_future_cancel2
(
self
):
f1
=
concurrent
.
futures
.
Future
()
f2
=
futures
.
wrap_future
(
f1
,
loop
=
self
.
loop
)
f1
.
set_result
(
42
)
f2
.
cancel
()
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertFalse
(
f1
.
cancelled
())
self
.
assertEqual
(
f1
.
result
(),
42
)
self
.
assertTrue
(
f2
.
cancelled
())
class
FutureDoneCallbackTests
(
unittest
.
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