D3336: py3: paper over differences in future exception handling
This revision was automatically updated to reflect the committed changes. Closed by commit rHG1cb54e6193a6: py3: paper over differences in future exception handling (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3336?vs=8205&id=8208 REVISION DETAIL https://phab.mercurial-scm.org/D3336 AFFECTED FILES mercurial/httppeer.py mercurial/localrepo.py mercurial/pycompat.py mercurial/wireprotov1peer.py CHANGE DETAILS diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py --- a/mercurial/wireprotov1peer.py +++ b/mercurial/wireprotov1peer.py @@ -209,7 +209,7 @@ try: result = fn(**pycompat.strkwargs(args)) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) else: f.set_result(result) @@ -234,14 +234,14 @@ batchable = fn.batchable(fn.__self__, **pycompat.strkwargs(args)) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) return # Encoded arguments and future holding remote result. try: encodedargs, fremote = next(batchable) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) return requests.append((command, encodedargs)) @@ -304,7 +304,7 @@ try: result = next(batchable) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) else: f.set_result(result) diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -28,6 +28,9 @@ import xmlrpclib from .thirdparty.concurrent import futures + +def future_set_exception_info(f, exc_info): +f.set_exception_info(*exc_info) else: import concurrent.futures as futures import http.cookiejar as cookielib @@ -37,6 +40,9 @@ import socketserver import xmlrpc.client as xmlrpclib +def future_set_exception_info(f, exc_info): +f.set_exception(exc_info[0]) + empty = _queue.Empty queue = _queue.Queue diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -184,7 +184,7 @@ try: result = fn(**args) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) else: f.set_result(result) diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -754,7 +754,8 @@ try: result.append(decoder.decode()) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info( +f, sys.exc_info()[1:]) continue else: result.append(meta['data']) To: durin42, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3336: py3: paper over differences in future exception handling
indygreg accepted this revision. indygreg added a comment. This revision is now accepted and ready to land. Ugh. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3336 To: durin42, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3336: py3: paper over differences in future exception handling
durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY It looks like Python 3's futures library lacks set_exception_info entirely. We'll just give up and use set_exception in that case. 1. no-check-commit because the underbar naming is just saner here REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3336 AFFECTED FILES mercurial/httppeer.py mercurial/localrepo.py mercurial/pycompat.py mercurial/wireprotov1peer.py CHANGE DETAILS diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py --- a/mercurial/wireprotov1peer.py +++ b/mercurial/wireprotov1peer.py @@ -209,7 +209,7 @@ try: result = fn(**pycompat.strkwargs(args)) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) else: f.set_result(result) @@ -234,14 +234,14 @@ batchable = fn.batchable(fn.__self__, **pycompat.strkwargs(args)) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) return # Encoded arguments and future holding remote result. try: encodedargs, fremote = next(batchable) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) return requests.append((command, encodedargs)) @@ -304,7 +304,7 @@ try: result = next(batchable) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) else: f.set_result(result) diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -28,6 +28,9 @@ import xmlrpclib from .thirdparty.concurrent import futures + +def future_set_exception_info(f, exc_info): +f.set_exception_info(*exc_info) else: import concurrent.futures as futures import http.cookiejar as cookielib @@ -37,6 +40,9 @@ import socketserver import xmlrpc.client as xmlrpclib +def future_set_exception_info(f, exc_info): +f.set_exception(exc_info[0]) + empty = _queue.Empty queue = _queue.Queue diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -184,7 +184,7 @@ try: result = fn(**args) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info(f, sys.exc_info()[1:]) else: f.set_result(result) diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -754,7 +754,8 @@ try: result.append(decoder.decode()) except Exception: -f.set_exception_info(*sys.exc_info()[1:]) +pycompat.future_set_exception_info( +f, sys.exc_info()[1:]) continue else: result.append(meta['data']) To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel