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
9e4e38ec
Kaydet (Commit)
9e4e38ec
authored
Eki 09, 2016
tarafından
INADA Naoki
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #26801: Added C implementation of asyncio.Future.
Original patch by Yury Selivanov.
üst
518599b2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
37 deletions
+67
-37
futures.py
Lib/asyncio/futures.py
+57
-37
NEWS
Misc/NEWS
+3
-0
Setup.dist
Modules/Setup.dist
+1
-0
_futuresmodule.c
Modules/_futuresmodule.c
+0
-0
pythoncore.vcxproj
PCbuild/pythoncore.vcxproj
+1
-0
pythoncore.vcxproj.filters
PCbuild/pythoncore.vcxproj.filters
+3
-0
setup.py
setup.py
+2
-0
No files found.
Lib/asyncio/futures.py
Dosyayı görüntüle @
9e4e38ec
...
...
@@ -120,6 +120,46 @@ def isfuture(obj):
return
getattr
(
obj
,
'_asyncio_future_blocking'
,
None
)
is
not
None
def
_format_callbacks
(
cb
):
"""helper function for Future.__repr__"""
size
=
len
(
cb
)
if
not
size
:
cb
=
''
def
format_cb
(
callback
):
return
events
.
_format_callback_source
(
callback
,
())
if
size
==
1
:
cb
=
format_cb
(
cb
[
0
])
elif
size
==
2
:
cb
=
'{}, {}'
.
format
(
format_cb
(
cb
[
0
]),
format_cb
(
cb
[
1
]))
elif
size
>
2
:
cb
=
'{}, <{} more>, {}'
.
format
(
format_cb
(
cb
[
0
]),
size
-
2
,
format_cb
(
cb
[
-
1
]))
return
'cb=[
%
s]'
%
cb
def
_future_repr_info
(
future
):
# (Future) -> str
"""helper function for Future.__repr__"""
info
=
[
future
.
_state
.
lower
()]
if
future
.
_state
==
_FINISHED
:
if
future
.
_exception
is
not
None
:
info
.
append
(
'exception={!r}'
.
format
(
future
.
_exception
))
else
:
# use reprlib to limit the length of the output, especially
# for very long strings
result
=
reprlib
.
repr
(
future
.
_result
)
info
.
append
(
'result={}'
.
format
(
result
))
if
future
.
_callbacks
:
info
.
append
(
_format_callbacks
(
future
.
_callbacks
))
if
future
.
_source_traceback
:
frame
=
future
.
_source_traceback
[
-
1
]
info
.
append
(
'created at
%
s:
%
s'
%
(
frame
[
0
],
frame
[
1
]))
return
info
class
Future
:
"""This class is *almost* compatible with concurrent.futures.Future.
...
...
@@ -172,45 +212,10 @@ class Future:
if
self
.
_loop
.
get_debug
():
self
.
_source_traceback
=
traceback
.
extract_stack
(
sys
.
_getframe
(
1
))
def
__format_callbacks
(
self
):
cb
=
self
.
_callbacks
size
=
len
(
cb
)
if
not
size
:
cb
=
''
def
format_cb
(
callback
):
return
events
.
_format_callback_source
(
callback
,
())
if
size
==
1
:
cb
=
format_cb
(
cb
[
0
])
elif
size
==
2
:
cb
=
'{}, {}'
.
format
(
format_cb
(
cb
[
0
]),
format_cb
(
cb
[
1
]))
elif
size
>
2
:
cb
=
'{}, <{} more>, {}'
.
format
(
format_cb
(
cb
[
0
]),
size
-
2
,
format_cb
(
cb
[
-
1
]))
return
'cb=[
%
s]'
%
cb
def
_repr_info
(
self
):
info
=
[
self
.
_state
.
lower
()]
if
self
.
_state
==
_FINISHED
:
if
self
.
_exception
is
not
None
:
info
.
append
(
'exception={!r}'
.
format
(
self
.
_exception
))
else
:
# use reprlib to limit the length of the output, especially
# for very long strings
result
=
reprlib
.
repr
(
self
.
_result
)
info
.
append
(
'result={}'
.
format
(
result
))
if
self
.
_callbacks
:
info
.
append
(
self
.
__format_callbacks
())
if
self
.
_source_traceback
:
frame
=
self
.
_source_traceback
[
-
1
]
info
.
append
(
'created at
%
s:
%
s'
%
(
frame
[
0
],
frame
[
1
]))
return
info
_repr_info
=
_future_repr_info
def
__repr__
(
self
):
info
=
self
.
_repr_info
()
return
'<
%
s
%
s>'
%
(
self
.
__class__
.
__name__
,
' '
.
join
(
info
))
return
'<
%
s
%
s>'
%
(
self
.
__class__
.
__name__
,
' '
.
join
(
self
.
_repr_info
()))
# On Python 3.3 and older, objects with a destructor part of a reference
# cycle are never destroyed. It's not more the case on Python 3.4 thanks
...
...
@@ -426,6 +431,21 @@ def _copy_future_state(source, dest):
dest
.
set_result
(
result
)
try
:
import
_futures
except
ImportError
:
pass
else
:
_futures
.
_init_module
(
traceback
.
extract_stack
,
events
.
get_event_loop
,
_future_repr_info
,
InvalidStateError
,
CancelledError
)
Future
=
_futures
.
Future
def
_chain_future
(
source
,
destination
):
"""Chain two futures so that when one completes, so does the other.
...
...
Misc/NEWS
Dosyayı görüntüle @
9e4e38ec
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 beta 2
Core and Builtins
-----------------
- Issue #26801: Added C implementation of asyncio.Future.
Original patch by Yury Selivanov.
- Issue #28379: Added sanity checks and tests for PyUnicode_CopyCharacters().
Patch by Xiang Zhang.
...
...
Modules/Setup.dist
Dosyayı görüntüle @
9e4e38ec
...
...
@@ -181,6 +181,7 @@ _symtable symtablemodule.c
#_datetime _datetimemodule.c # datetime accelerator
#_bisect _bisectmodule.c # Bisection algorithms
#_heapq _heapqmodule.c # Heap queue algorithm
#_futures _futuresmodule.c # Fast asyncio Future
#unicodedata unicodedata.c # static Unicode character database
...
...
Modules/_futuresmodule.c
0 → 100644
Dosyayı görüntüle @
9e4e38ec
This diff is collapsed.
Click to expand it.
PCbuild/pythoncore.vcxproj
Dosyayı görüntüle @
9e4e38ec
...
...
@@ -221,6 +221,7 @@
<ClCompile
Include=
"..\Modules\_collectionsmodule.c"
/>
<ClCompile
Include=
"..\Modules\_csv.c"
/>
<ClCompile
Include=
"..\Modules\_functoolsmodule.c"
/>
<ClCompile
Include=
"..\Modules\_futuresmodule.c"
/>
<ClCompile
Include=
"..\Modules\_heapqmodule.c"
/>
<ClCompile
Include=
"..\Modules\_json.c"
/>
<ClCompile
Include=
"..\Modules\_localemodule.c"
/>
...
...
PCbuild/pythoncore.vcxproj.filters
Dosyayı görüntüle @
9e4e38ec
...
...
@@ -470,6 +470,9 @@
<ClCompile
Include=
"..\Modules\_functoolsmodule.c"
>
<Filter>
Modules
</Filter>
</ClCompile>
<ClCompile
Include=
"..\Modules\_futuresmodule.c"
>
<Filter>
Modules
</Filter>
</ClCompile>
<ClCompile
Include=
"..\Modules\_heapqmodule.c"
>
<Filter>
Modules
</Filter>
</ClCompile>
...
...
setup.py
Dosyayı görüntüle @
9e4e38ec
...
...
@@ -656,6 +656,8 @@ class PyBuildExt(build_ext):
depends
=
[
'unicodedata_db.h'
,
'unicodename_db.h'
])
)
# _opcode module
exts
.
append
(
Extension
(
'_opcode'
,
[
'_opcode.c'
])
)
# Fast asyncio Future implementation
exts
.
append
(
Extension
(
"_futures"
,
[
"_futuresmodule.c"
])
)
# Modules with some UNIX dependencies -- on by default:
# (If you have a really backward UNIX, select and socket may not be
...
...
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