Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
21aad979
Commit
21aad979
authored
Oct 28, 2013
by
Richard Oudkerk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19425 -- a pickling error should not cause pool to hang.
parent
9a2325fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
Lib/multiprocessing/pool.py
Lib/multiprocessing/pool.py
+9
-5
Lib/test/test_multiprocessing.py
Lib/test/test_multiprocessing.py
+10
-0
No files found.
Lib/multiprocessing/pool.py
View file @
21aad979
...
...
@@ -169,7 +169,8 @@ class Pool(object):
self
.
_task_handler
=
threading
.
Thread
(
target
=
Pool
.
_handle_tasks
,
args
=
(
self
.
_taskqueue
,
self
.
_quick_put
,
self
.
_outqueue
,
self
.
_pool
)
args
=
(
self
.
_taskqueue
,
self
.
_quick_put
,
self
.
_outqueue
,
self
.
_pool
,
self
.
_cache
)
)
self
.
_task_handler
.
daemon
=
True
self
.
_task_handler
.
_state
=
RUN
...
...
@@ -329,7 +330,7 @@ class Pool(object):
debug
(
'worker handler exiting'
)
@
staticmethod
def
_handle_tasks
(
taskqueue
,
put
,
outqueue
,
pool
):
def
_handle_tasks
(
taskqueue
,
put
,
outqueue
,
pool
,
cache
):
thread
=
threading
.
current_thread
()
for
taskseq
,
set_length
in
iter
(
taskqueue
.
get
,
None
):
...
...
@@ -340,9 +341,12 @@ class Pool(object):
break
try
:
put
(
task
)
except
IOError
:
debug
(
'could not put task on queue'
)
break
except
Exception
as
e
:
job
,
ind
=
task
[:
2
]
try
:
cache
[
job
].
_set
(
ind
,
(
False
,
e
))
except
KeyError
:
pass
else
:
if
set_length
:
debug
(
'doing set_length()'
)
...
...
Lib/test/test_multiprocessing.py
View file @
21aad979
...
...
@@ -1117,6 +1117,16 @@ class _TestPool(BaseTestCase):
self
.
assertEqual
(
pmap
(
sqr
,
range
(
100
),
chunksize
=
20
),
map
(
sqr
,
range
(
100
)))
def
test_map_unplicklable
(
self
):
# Issue #19425 -- failure to pickle should not cause a hang
if
self
.
TYPE
==
'threads'
:
return
class
A
(
object
):
def
__reduce__
(
self
):
raise
RuntimeError
(
'cannot pickle'
)
with
self
.
assertRaises
(
RuntimeError
):
self
.
pool
.
map
(
sqr
,
[
A
()]
*
10
)
def
test_map_chunksize
(
self
):
try
:
self
.
pool
.
map_async
(
sqr
,
[],
chunksize
=
1
).
get
(
timeout
=
TIMEOUT1
)
...
...
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