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
3e09e32c
Kaydet (Commit)
3e09e32c
authored
Ara 03, 2013
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
asyncio doc: move coroutine example to the Task page
üst
ea3183f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
19 deletions
+32
-19
asyncio-eventloop.rst
Doc/library/asyncio-eventloop.rst
+9
-19
asyncio-task.rst
Doc/library/asyncio-task.rst
+23
-0
No files found.
Doc/library/asyncio-eventloop.rst
Dosyayı görüntüle @
3e09e32c
...
@@ -144,6 +144,10 @@ a different clock than :func:`time.time`.
...
@@ -144,6 +144,10 @@ a different clock than :func:`time.time`.
Return the current time, as a :class:`float` value, according to the
Return the current time, as a :class:`float` value, according to the
event loop's internal clock.
event loop's internal clock.
.. seealso::
The :func:`asyncio.sleep` function.
Creating connections
Creating connections
^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^
...
@@ -330,11 +334,10 @@ pool of processes). By default, an event loop uses a thread pool executor
...
@@ -330,11 +334,10 @@ pool of processes). By default, an event loop uses a thread pool executor
Set the default executor used by :meth:`run_in_executor`.
Set the default executor used by :meth:`run_in_executor`.
Examples
.. _asyncio-hello-world-callback:
--------
Hello World (callback)
Example:
Hello World (callback)
^^^^^^^^^^^^^^^^^^^^^^
-------------------------------
Print ``Hello World`` every two seconds, using a callback::
Print ``Hello World`` every two seconds, using a callback::
...
@@ -348,20 +351,7 @@ Print ``Hello World`` every two seconds, using a callback::
...
@@ -348,20 +351,7 @@ Print ``Hello World`` every two seconds, using a callback::
print_and_repeat(loop)
print_and_repeat(loop)
loop.run_forever()
loop.run_forever()
.. seealso::
Hello World (coroutine)
:ref:`Hello World example using a coroutine <asyncio-hello-world-coroutine>`.
^^^^^^^^^^^^^^^^^^^^^^^
Print ``Hello World`` every two seconds, using a coroutine::
import asyncio
@asyncio.coroutine
def greet_every_two_seconds():
while True:
print('Hello World')
yield from asyncio.sleep(2)
loop = asyncio.get_event_loop()
loop.run_until_complete(greet_every_two_seconds())
Doc/library/asyncio-task.rst
Dosyayı görüntüle @
3e09e32c
...
@@ -230,3 +230,26 @@ Task functions
...
@@ -230,3 +230,26 @@ Task functions
This does not raise :exc:`TimeoutError`! Futures that aren't done when
This does not raise :exc:`TimeoutError`! Futures that aren't done when
the timeout occurs are returned in the second set.
the timeout occurs are returned in the second set.
.. _asyncio-hello-world-coroutine:
Example: Hello World (coroutine)
--------------------------------
Print ``Hello World`` every two seconds, using a coroutine::
import asyncio
@asyncio.coroutine
def greet_every_two_seconds():
while True:
print('Hello World')
yield from asyncio.sleep(2)
loop = asyncio.get_event_loop()
loop.run_until_complete(greet_every_two_seconds())
.. seealso::
:ref:`Hello World example using a callback <asyncio-hello-world-callback>`.
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