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
e65617f6
Kaydet (Commit)
e65617f6
authored
Kas 07, 2017
tarafından
Miss Islington (bot)
Kaydeden (comit)
Antoine Pitrou
Kas 07, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-31950: Improve event loop policy doc (GH-4306) (#4307)
(cherry picked from commit
4135c893
)
üst
b0331c94
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
asyncio-eventloops.rst
Doc/library/asyncio-eventloops.rst
+30
-3
No files found.
Doc/library/asyncio-eventloops.rst
Dosyayı görüntüle @
e65617f6
...
@@ -148,10 +148,9 @@ process based on the calling context. A policy is an object implementing the
...
@@ -148,10 +148,9 @@ process based on the calling context. A policy is an object implementing the
:class:`AbstractEventLoopPolicy` interface.
:class:`AbstractEventLoopPolicy` interface.
For most users of :mod:`asyncio`, policies never have to be dealt with
For most users of :mod:`asyncio`, policies never have to be dealt with
explicitly, since the default global policy is sufficient.
explicitly, since the default global policy is sufficient
(see below)
.
The default policy defines context as the current thread, and manages an event
The module-level functions
loop per thread that interacts with :mod:`asyncio`. The module-level functions
:func:`get_event_loop` and :func:`set_event_loop` provide convenient access to
:func:`get_event_loop` and :func:`set_event_loop` provide convenient access to
event loops managed by the default policy.
event loops managed by the default policy.
...
@@ -189,6 +188,13 @@ An event loop policy must implement the following interface:
...
@@ -189,6 +188,13 @@ An event loop policy must implement the following interface:
context, :meth:`set_event_loop` must be called explicitly.
context, :meth:`set_event_loop` must be called explicitly.
The default policy defines context as the current thread, and manages an event
loop per thread that interacts with :mod:`asyncio`. If the current thread
doesn't already have an event loop associated with it, the default policy's
:meth:`~AbstractEventLoopPolicy.get_event_loop` method creates one when
called from the main thread, but raises :exc:`RuntimeError` otherwise.
Access to the global loop policy
Access to the global loop policy
--------------------------------
--------------------------------
...
@@ -200,3 +206,24 @@ Access to the global loop policy
...
@@ -200,3 +206,24 @@ Access to the global loop policy
Set the current event loop policy. If *policy* is ``None``, the default
Set the current event loop policy. If *policy* is ``None``, the default
policy is restored.
policy is restored.
Customizing the event loop policy
---------------------------------
To implement a new event loop policy, it is recommended you subclass the
concrete default event loop policy :class:`DefaultEventLoopPolicy`
and override the methods for which you want to change behavior, for example::
class MyEventLoopPolicy(asyncio.DefaultEventLoopPolicy):
def get_event_loop(self):
"""Get the event loop.
This may be None or an instance of EventLoop.
"""
loop = super().get_event_loop()
# Do something with loop ...
return loop
asyncio.set_event_loop_policy(MyEventLoopPolicy())
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