Mercurial > hg
comparison mercurial/wireprotov1peer.py @ 37669:1cb54e6193a6
py3: paper over differences in future exception handling
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.
# no-check-commit because the underbar naming is just saner here
Differential Revision: https://phab.mercurial-scm.org/D3336
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 13 Apr 2018 18:17:45 -0400 |
parents | 62ebfda864de |
children | 856f381ad74b |
comparison
equal
deleted
inserted
replaced
37668:2a42ca2679e2 | 37669:1cb54e6193a6 |
---|---|
207 return | 207 return |
208 | 208 |
209 try: | 209 try: |
210 result = fn(**pycompat.strkwargs(args)) | 210 result = fn(**pycompat.strkwargs(args)) |
211 except Exception: | 211 except Exception: |
212 f.set_exception_info(*sys.exc_info()[1:]) | 212 pycompat.future_set_exception_info(f, sys.exc_info()[1:]) |
213 else: | 213 else: |
214 f.set_result(result) | 214 f.set_result(result) |
215 | 215 |
216 return | 216 return |
217 | 217 |
232 | 232 |
233 try: | 233 try: |
234 batchable = fn.batchable(fn.__self__, | 234 batchable = fn.batchable(fn.__self__, |
235 **pycompat.strkwargs(args)) | 235 **pycompat.strkwargs(args)) |
236 except Exception: | 236 except Exception: |
237 f.set_exception_info(*sys.exc_info()[1:]) | 237 pycompat.future_set_exception_info(f, sys.exc_info()[1:]) |
238 return | 238 return |
239 | 239 |
240 # Encoded arguments and future holding remote result. | 240 # Encoded arguments and future holding remote result. |
241 try: | 241 try: |
242 encodedargs, fremote = next(batchable) | 242 encodedargs, fremote = next(batchable) |
243 except Exception: | 243 except Exception: |
244 f.set_exception_info(*sys.exc_info()[1:]) | 244 pycompat.future_set_exception_info(f, sys.exc_info()[1:]) |
245 return | 245 return |
246 | 246 |
247 requests.append((command, encodedargs)) | 247 requests.append((command, encodedargs)) |
248 states.append((command, f, batchable, fremote)) | 248 states.append((command, f, batchable, fremote)) |
249 | 249 |
302 | 302 |
303 # And ask the coroutine to decode that value. | 303 # And ask the coroutine to decode that value. |
304 try: | 304 try: |
305 result = next(batchable) | 305 result = next(batchable) |
306 except Exception: | 306 except Exception: |
307 f.set_exception_info(*sys.exc_info()[1:]) | 307 pycompat.future_set_exception_info(f, sys.exc_info()[1:]) |
308 else: | 308 else: |
309 f.set_result(result) | 309 f.set_result(result) |
310 | 310 |
311 @zi.implementer(repository.ipeercommands, repository.ipeerlegacycommands) | 311 @zi.implementer(repository.ipeercommands, repository.ipeerlegacycommands) |
312 class wirepeer(repository.peer): | 312 class wirepeer(repository.peer): |