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
e247b46c
Unverified
Kaydet (Commit)
e247b46c
authored
Eyl 20, 2018
tarafından
Yury Selivanov
Kaydeden (comit)
GitHub
Eyl 20, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-33649: More improvements (GH-9439)
üst
8213eadd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
4 deletions
+45
-4
asyncio-eventloop.rst
Doc/library/asyncio-eventloop.rst
+45
-4
asyncio-task.rst
Doc/library/asyncio-task.rst
+0
-0
No files found.
Doc/library/asyncio-eventloop.rst
Dosyayı görüntüle @
e247b46c
...
...
@@ -755,7 +755,7 @@ Watching file descriptors
invoke *callback* with the specified arguments once *fd* is available for
writing.
Use :func:`functools.partial` :ref:`to pass keywords
Use :func:`functools.partial` :ref:`to pass keyword
argument
s
<asyncio-pass-keywords>` to *func*.
.. method:: loop.remove_writer(fd)
...
...
@@ -969,7 +969,7 @@ Unix signals
Raise :exc:`ValueError` if the signal number is invalid or uncatchable.
Raise :exc:`RuntimeError` if there is a problem setting up the handler.
Use :func:`functools.partial` :ref:`to pass keywords
Use :func:`functools.partial` :ref:`to pass keyword
argument
s
<asyncio-pass-keywords>` to *func*.
.. method:: loop.remove_signal_handler(sig)
...
...
@@ -996,11 +996,52 @@ Executing code in thread or process pools
The *executor* argument should be an :class:`concurrent.futures.Executor`
instance. The default executor is used if *executor* is ``None``.
Use :func:`functools.partial` :ref:`to pass keywords
<asyncio-pass-keywords>` to *func*.
Example::
import asyncio
import concurrent.futures
def blocking_io():
# File operations (such as logging) can block the
# event loop: run them in a thread pool.
with open('/dev/urandom', 'rb') as f:
return f.read(100)
def cpu_bound():
# CPU-bound operations will block the event loop:
# in general it is preferable to run them in a
# process pool.
return sum(i * i for i in range(10 ** 7))
async def main():
loop = asyncio.get_running_loop()
## Options:
# 1. Run in the default loop's executor:
result = await loop.run_in_executor(
None, blocking_io)
print('default thread pool', result)
# 2. Run in a custom thread pool:
with concurrent.futures.ThreadPoolExecutor() as pool:
result = await loop.run_in_executor(
pool, blocking_io)
print('custom thread pool', result)
# 3. Run in a custom process pool:
with concurrent.futures.ProcessPoolExecutor() as pool:
result = await loop.run_in_executor(
pool, cpu_bound)
print('custom process pool', result)
asyncio.run(main())
This method returns a :class:`asyncio.Future` object.
Use :func:`functools.partial` :ref:`to pass keyword arguments
<asyncio-pass-keywords>` to *func*.
.. versionchanged:: 3.5.3
:meth:`loop.run_in_executor` no longer configures the
``max_workers`` of the thread pool executor it creates, instead
...
...
Doc/library/asyncio-task.rst
Dosyayı görüntüle @
e247b46c
This diff is collapsed.
Click to expand it.
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