Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commandserver.py @ 40450:41f0529b5112 stable
commandserver: get around ETIMEDOUT raised by selectors2
selector.select() should exits with an empty event list on timed out, but
selectors2 raises OSError if timeout expires while recovering from EINTR.
Spotted while debugging new chg feature.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 03 Dec 2018 21:45:15 +0900 |
parents | b7de186efd82 |
children | cb372d09d30a |
comparison
equal
deleted
inserted
replaced
40449:d1bda397df73 | 40450:41f0529b5112 |
---|---|
470 # for requests that are queued (connect()-ed, but haven't been | 470 # for requests that are queued (connect()-ed, but haven't been |
471 # accept()-ed), handle them before exit. otherwise, clients | 471 # accept()-ed), handle them before exit. otherwise, clients |
472 # waiting for recv() will receive ECONNRESET. | 472 # waiting for recv() will receive ECONNRESET. |
473 self._unlinksocket() | 473 self._unlinksocket() |
474 exiting = True | 474 exiting = True |
475 ready = selector.select(timeout=h.pollinterval) | 475 try: |
476 ready = selector.select(timeout=h.pollinterval) | |
477 except OSError as inst: | |
478 # selectors2 raises ETIMEDOUT if timeout exceeded while | |
479 # handling signal interrupt. That's probably wrong, but | |
480 # we can easily get around it. | |
481 if inst.errno != errno.ETIMEDOUT: | |
482 raise | |
483 ready = [] | |
476 if not ready: | 484 if not ready: |
477 # only exit if we completed all queued requests | 485 # only exit if we completed all queued requests |
478 if exiting: | 486 if exiting: |
479 break | 487 break |
480 continue | 488 continue |