Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 526914 Details for
Bug 647964
app-portage/gemato-14.1m: deadlock?
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Use concurrent.futures.ProcessPoolExecutor for python3.5+
0001-Use-ProcessPoolExecutor-bug-647964.patch (text/plain), 2.37 KB, created by
Zac Medico
on 2018-04-09 16:10:59 UTC
(
hide
)
Description:
Use concurrent.futures.ProcessPoolExecutor for python3.5+
Filename:
MIME Type:
Creator:
Zac Medico
Created:
2018-04-09 16:10:59 UTC
Size:
2.37 KB
patch
obsolete
>From 3cc21290a97ea0b734179054b354be3ef9696313 Mon Sep 17 00:00:00 2001 >From: Zac Medico <zmedico@gentoo.org> >Date: Mon, 9 Apr 2018 09:07:04 -0700 >Subject: [PATCH] Use ProcessPoolExecutor (bug 647964) > >Use ProcessPoolExecutor as a possible workaround for imap_unordered >deadlock. > >Bug: https://bugs.gentoo.org/647964 >--- > gemato/util.py | 31 ++++++++++++++++++++----------- > 1 file changed, 20 insertions(+), 11 deletions(-) > >diff --git a/gemato/util.py b/gemato/util.py >index eb052b6..7563ec4 100644 >--- a/gemato/util.py >+++ b/gemato/util.py >@@ -6,6 +6,11 @@ > import multiprocessing > import sys > >+try: >+ from concurrent.futures import ProcessPoolExecutor >+except ImportError: >+ ProcessPoolExecutor = None >+ > > class MultiprocessingPoolWrapper(object): > """ >@@ -16,16 +21,25 @@ class MultiprocessingPoolWrapper(object): > __slots__ = ['pool'] > > def __init__(self, processes): >- self.pool = multiprocessing.Pool(processes=processes) >+ # ProcessPoolExecutor.map supports chunksize in python3.5+, >+ # use it as a possible workaround for imap_unordered deadlock >+ # reported in https://bugs.gentoo.org/647964. >+ if sys.version_info >= (3, 5): >+ self.pool = ProcessPoolExecutor(max_workers=processes) >+ else: >+ self.pool = multiprocessing.Pool(processes=processes) > > def __enter__(self): > return self > > def __exit__(self, exc_type, exc_value, exc_cb): >- if exc_type is None: >- self.pool.close() >- self.pool.join() >- self.pool.terminate() >+ if hasattr(self.pool, 'shutdown'): >+ self.pool.shutdown() >+ else: >+ if exc_type is None: >+ self.pool.close() >+ self.pool.join() >+ self.pool.terminate() > > def map(self, *args, **kwargs): > return self.pool.map(*args, **kwargs) >@@ -35,12 +49,7 @@ class MultiprocessingPoolWrapper(object): > Use imap_unordered() if available and safe to use. Fall back > to regular map() otherwise. > """ >- if sys.hexversion >= 0x03050400: >- return self.pool.imap_unordered(*args, **kwargs) >- else: >- # in py<3.5.4 imap() swallows exceptions, so fall back >- # to regular map() >- return self.pool.map(*args, **kwargs) >+ return self.pool.map(*args, **kwargs) > > > def path_starts_with(path, prefix): >-- >2.13.6 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 647964
:
519908
|
523086
|
523828
| 526914 |
526984