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
80a5be1d
Kaydet (Commit)
80a5be1d
authored
Mar 23, 2014
tarafından
Richard Oudkerk
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20980: Stop wrapping exception when using ThreadPool.
üst
a40675a1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
6 deletions
+30
-6
managers.py
Lib/multiprocessing/managers.py
+8
-3
pool.py
Lib/multiprocessing/pool.py
+9
-3
_test_multiprocessing.py
Lib/test/_test_multiprocessing.py
+11
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/multiprocessing/managers.py
Dosyayı görüntüle @
80a5be1d
...
...
@@ -1077,17 +1077,22 @@ ArrayProxy = MakeProxyType('ArrayProxy', (
))
PoolProxy
=
MakeProxyType
(
'PoolProxy'
,
(
Base
PoolProxy
=
MakeProxyType
(
'PoolProxy'
,
(
'apply'
,
'apply_async'
,
'close'
,
'imap'
,
'imap_unordered'
,
'join'
,
'map'
,
'map_async'
,
'starmap'
,
'starmap_async'
,
'terminate'
'map'
,
'map_async'
,
'starmap'
,
'starmap_async'
,
'terminate'
,
))
PoolProxy
.
_method_to_typeid_
=
{
Base
PoolProxy
.
_method_to_typeid_
=
{
'apply_async'
:
'AsyncResult'
,
'map_async'
:
'AsyncResult'
,
'starmap_async'
:
'AsyncResult'
,
'imap'
:
'Iterator'
,
'imap_unordered'
:
'Iterator'
}
class
PoolProxy
(
BasePoolProxy
):
def
__enter__
(
self
):
return
self
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
self
.
terminate
()
#
# Definition of SyncManager
...
...
Lib/multiprocessing/pool.py
Dosyayı görüntüle @
80a5be1d
...
...
@@ -90,7 +90,8 @@ class MaybeEncodingError(Exception):
return
"<MaybeEncodingError:
%
s>"
%
str
(
self
)
def
worker
(
inqueue
,
outqueue
,
initializer
=
None
,
initargs
=
(),
maxtasks
=
None
):
def
worker
(
inqueue
,
outqueue
,
initializer
=
None
,
initargs
=
(),
maxtasks
=
None
,
wrap_exception
=
False
):
assert
maxtasks
is
None
or
(
type
(
maxtasks
)
==
int
and
maxtasks
>
0
)
put
=
outqueue
.
put
get
=
inqueue
.
get
...
...
@@ -117,7 +118,8 @@ def worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None):
try
:
result
=
(
True
,
func
(
*
args
,
**
kwds
))
except
Exception
as
e
:
e
=
ExceptionWithTraceback
(
e
,
e
.
__traceback__
)
if
wrap_exception
:
e
=
ExceptionWithTraceback
(
e
,
e
.
__traceback__
)
result
=
(
False
,
e
)
try
:
put
((
job
,
i
,
result
))
...
...
@@ -137,6 +139,8 @@ class Pool(object):
'''
Class which supports an async version of applying functions to arguments.
'''
_wrap_exception
=
True
def
Process
(
self
,
*
args
,
**
kwds
):
return
self
.
_ctx
.
Process
(
*
args
,
**
kwds
)
...
...
@@ -220,7 +224,8 @@ class Pool(object):
w
=
self
.
Process
(
target
=
worker
,
args
=
(
self
.
_inqueue
,
self
.
_outqueue
,
self
.
_initializer
,
self
.
_initargs
,
self
.
_maxtasksperchild
)
self
.
_initargs
,
self
.
_maxtasksperchild
,
self
.
_wrap_exception
)
)
self
.
_pool
.
append
(
w
)
w
.
name
=
w
.
name
.
replace
(
'Process'
,
'PoolWorker'
)
...
...
@@ -736,6 +741,7 @@ class IMapUnorderedIterator(IMapIterator):
#
class
ThreadPool
(
Pool
):
_wrap_exception
=
False
@staticmethod
def
Process
(
*
args
,
**
kwds
):
...
...
Lib/test/_test_multiprocessing.py
Dosyayı görüntüle @
80a5be1d
...
...
@@ -1810,6 +1810,17 @@ class _TestPool(BaseTestCase):
self
.
assertIn
(
'raise RuntimeError(123) # some comment'
,
f1
.
getvalue
())
@classmethod
def
_test_wrapped_exception
(
cls
):
raise
RuntimeError
(
'foo'
)
def
test_wrapped_exception
(
self
):
# Issue #20980: Should not wrap exception when using thread pool
with
self
.
Pool
(
1
)
as
p
:
with
self
.
assertRaises
(
RuntimeError
):
p
.
apply
(
self
.
_test_wrapped_exception
)
def
raising
():
raise
KeyError
(
"key"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
80a5be1d
...
...
@@ -21,6 +21,8 @@ Core and Builtins
Library
-------
- Issue #20980: Stop wrapping exception when using ThreadPool.
- Issue #20990: Fix issues found by pyflakes for multiprocessing.
- Issue #21015: SSL contexts will now automatically select an elliptic
...
...
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