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
abae67eb
Unverified
Kaydet (Commit)
abae67eb
authored
Ara 11, 2017
tarafından
Yury Selivanov
Kaydeden (comit)
GitHub
Ara 11, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add asyncio.get_running_loop() function. (#4782)
üst
3e975181
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
1 deletion
+27
-1
asyncio-eventloops.rst
Doc/library/asyncio-eventloops.rst
+7
-0
events.py
Lib/asyncio/events.py
+13
-1
test_events.py
Lib/test/test_asyncio/test_events.py
+6
-0
2017-12-10-12-30-13.bpo-32269.Q85pKj.rst
...S.d/next/Library/2017-12-10-12-30-13.bpo-32269.Q85pKj.rst
+1
-0
No files found.
Doc/library/asyncio-eventloops.rst
Dosyayı görüntüle @
abae67eb
...
...
@@ -25,6 +25,13 @@ the execution of the process.
Equivalent to calling ``get_event_loop_policy().new_event_loop()``.
.. function:: get_running_loop()
Return the running event loop in the current OS thread. If there
is no running event loop a :exc:`RuntimeError` is raised.
.. versionadded:: 3.7
.. _asyncio-event-loops:
...
...
Lib/asyncio/events.py
Dosyayı görüntüle @
abae67eb
...
...
@@ -7,7 +7,8 @@ __all__ = (
'get_event_loop_policy'
,
'set_event_loop_policy'
,
'get_event_loop'
,
'set_event_loop'
,
'new_event_loop'
,
'get_child_watcher'
,
'set_child_watcher'
,
'_set_running_loop'
,
'_get_running_loop'
,
'_set_running_loop'
,
'get_running_loop'
,
'_get_running_loop'
,
)
import
functools
...
...
@@ -646,6 +647,17 @@ class _RunningLoop(threading.local):
_running_loop
=
_RunningLoop
()
def
get_running_loop
():
"""Return the running event loop. Raise a RuntimeError if there is none.
This function is thread-specific.
"""
loop
=
_get_running_loop
()
if
loop
is
None
:
raise
RuntimeError
(
'no running event loop'
)
return
loop
def
_get_running_loop
():
"""Return the running event loop or None.
...
...
Lib/test/test_asyncio/test_events.py
Dosyayı görüntüle @
abae67eb
...
...
@@ -2733,10 +2733,13 @@ class PolicyTests(unittest.TestCase):
try
:
asyncio
.
set_event_loop_policy
(
Policy
())
loop
=
asyncio
.
new_event_loop
()
with
self
.
assertRaisesRegex
(
RuntimeError
,
'no running'
):
self
.
assertIs
(
asyncio
.
get_running_loop
(),
None
)
self
.
assertIs
(
asyncio
.
_get_running_loop
(),
None
)
async
def
func
():
self
.
assertIs
(
asyncio
.
get_event_loop
(),
loop
)
self
.
assertIs
(
asyncio
.
get_running_loop
(),
loop
)
self
.
assertIs
(
asyncio
.
_get_running_loop
(),
loop
)
loop
.
run_until_complete
(
func
())
...
...
@@ -2745,6 +2748,9 @@ class PolicyTests(unittest.TestCase):
if
loop
is
not
None
:
loop
.
close
()
with
self
.
assertRaisesRegex
(
RuntimeError
,
'no running'
):
self
.
assertIs
(
asyncio
.
get_running_loop
(),
None
)
self
.
assertIs
(
asyncio
.
_get_running_loop
(),
None
)
...
...
Misc/NEWS.d/next/Library/2017-12-10-12-30-13.bpo-32269.Q85pKj.rst
0 → 100644
Dosyayı görüntüle @
abae67eb
Add asyncio.get_running_loop() function.
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