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
692130a2
Kaydet (Commit)
692130a2
authored
May 25, 2012
tarafından
Richard Oudkerk
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #12091: simplify ApplyResult and MapResult with threading.Event
Patch by Charles-François Natali
üst
be39cfc9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
30 deletions
+9
-30
pool.py
Lib/multiprocessing/pool.py
+9
-30
No files found.
Lib/multiprocessing/pool.py
Dosyayı görüntüle @
692130a2
...
...
@@ -526,32 +526,26 @@ class Pool(object):
class
ApplyResult
(
object
):
def
__init__
(
self
,
cache
,
callback
,
error_callback
):
self
.
_
cond
=
threading
.
Condition
(
threading
.
Lock
()
)
self
.
_
event
=
threading
.
Event
(
)
self
.
_job
=
next
(
job_counter
)
self
.
_cache
=
cache
self
.
_ready
=
False
self
.
_callback
=
callback
self
.
_error_callback
=
error_callback
cache
[
self
.
_job
]
=
self
def
ready
(
self
):
return
self
.
_
ready
return
self
.
_
event
.
is_set
()
def
successful
(
self
):
assert
self
.
_ready
assert
self
.
ready
()
return
self
.
_success
def
wait
(
self
,
timeout
=
None
):
self
.
_cond
.
acquire
()
try
:
if
not
self
.
_ready
:
self
.
_cond
.
wait
(
timeout
)
finally
:
self
.
_cond
.
release
()
self
.
_event
.
wait
(
timeout
)
def
get
(
self
,
timeout
=
None
):
self
.
wait
(
timeout
)
if
not
self
.
_ready
:
if
not
self
.
ready
()
:
raise
TimeoutError
if
self
.
_success
:
return
self
.
_value
...
...
@@ -564,12 +558,7 @@ class ApplyResult(object):
self
.
_callback
(
self
.
_value
)
if
self
.
_error_callback
and
not
self
.
_success
:
self
.
_error_callback
(
self
.
_value
)
self
.
_cond
.
acquire
()
try
:
self
.
_ready
=
True
self
.
_cond
.
notify
()
finally
:
self
.
_cond
.
release
()
self
.
_event
.
set
()
del
self
.
_cache
[
self
.
_job
]
#
...
...
@@ -586,7 +575,7 @@ class MapResult(ApplyResult):
self
.
_chunksize
=
chunksize
if
chunksize
<=
0
:
self
.
_number_left
=
0
self
.
_
ready
=
True
self
.
_
event
.
set
()
else
:
self
.
_number_left
=
length
//
chunksize
+
bool
(
length
%
chunksize
)
...
...
@@ -599,24 +588,14 @@ class MapResult(ApplyResult):
if
self
.
_callback
:
self
.
_callback
(
self
.
_value
)
del
self
.
_cache
[
self
.
_job
]
self
.
_cond
.
acquire
()
try
:
self
.
_ready
=
True
self
.
_cond
.
notify
()
finally
:
self
.
_cond
.
release
()
self
.
_event
.
set
()
else
:
self
.
_success
=
False
self
.
_value
=
result
if
self
.
_error_callback
:
self
.
_error_callback
(
self
.
_value
)
del
self
.
_cache
[
self
.
_job
]
self
.
_cond
.
acquire
()
try
:
self
.
_ready
=
True
self
.
_cond
.
notify
()
finally
:
self
.
_cond
.
release
()
self
.
_event
.
set
()
#
# Class whose instances are returned by `Pool.imap()`
...
...
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