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
606ab031
Kaydet (Commit)
606ab031
authored
Şub 01, 2014
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
asyncio doc: add "Concurrency and multithreading" section
üst
45b27ed5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
4 deletions
+28
-4
asyncio-dev.rst
Doc/library/asyncio-dev.rst
+27
-3
asyncio-sync.rst
Doc/library/asyncio-sync.rst
+1
-1
No files found.
Doc/library/asyncio-dev.rst
Dosyayı görüntüle @
606ab031
...
...
@@ -7,6 +7,32 @@ Asynchronous programming is different than classical "sequential" programming.
This page lists common traps and explains how to avoid them.
.. _asyncio-multithreading:
Concurrency and multithreading
------------------------------
An event loop runs in a thread and executes all callbacks and tasks in the same
thread. If a callback should be scheduled from a different thread, the
:meth:`BaseEventLoop.call_soon_threadsafe` method should be used.
While a task in running in the event loop, no other task is running in the same
thread. But when the task uses ``yield from``, the task is suspended and the
event loop executes the next task.
To handle signals and to execute subprocesses, the event loop must be run in
the main thread.
The :meth:`BaseEventLoop.run_in_executor` method can be used with a thread pool
executor to execute a callback in different thread to not block the thread of
the event loop.
.. seealso::
See the :ref:`Synchronization primitives <asyncio-sync>` section to
synchronize tasks.
.. _asyncio-handle-blocking:
Handle correctly blocking functions
...
...
@@ -21,7 +47,7 @@ APIs like :ref:`protocols <protocol>`.
An executor can be used to run a task in a different thread or even in a
different process, to not block the thread of the event loop. See the
:
func:`BaseEventLoop.run_in_executor` function
.
:
meth:`BaseEventLoop.run_in_executor` method
.
.. seealso::
...
...
@@ -213,5 +239,3 @@ Or without ``asyncio.async()``::
yield from asyncio.sleep(2.0)
loop.stop()
.. XXX: Document "poll xxx" log message?
Doc/library/asyncio-sync.rst
Dosyayı görüntüle @
606ab031
.. currentmodule:: asyncio
.. _sync:
.. _
asyncio-
sync:
Synchronization primitives
==========================
...
...
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