Mercurial > public > mercurial-scm > hg
comparison mercurial/worker.py @ 49280:311fcc5a65f6
thirdparty: remove Python 2-specific selectors2 copy
The selectors module was added in Python 3.4. Because we require Python 3.6, it
will always be available. Therefore the selectors2 module is not imported.
I?ve verified that the selectors2-specific workaround in commandserver.py is not
necessary with the selectors module from the standard library. It returns an
empty list if timeout was exceeded.
The pytype directive was needed to silence the following error:
File "/tmp/mercurial-ci/mercurial/worker.py", line 299, in _posixworker: No attribute 'close' on int [attribute-error]
In Union[_typeshed.HasFileno, int]
File "/tmp/mercurial-ci/mercurial/worker.py", line 299, in _posixworker: No attribute 'close' on _typeshed.HasFileno [attribute-error]
In Union[_typeshed.HasFileno, int]
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Sat, 28 May 2022 22:08:13 +0200 |
parents | 395f28064826 |
children | ee4537e365c8 |
comparison
equal
deleted
inserted
replaced
49279:127d33e63d1a | 49280:311fcc5a65f6 |
---|---|
7 | 7 |
8 | 8 |
9 import errno | 9 import errno |
10 import os | 10 import os |
11 import pickle | 11 import pickle |
12 import selectors | |
12 import signal | 13 import signal |
13 import sys | 14 import sys |
14 import threading | 15 import threading |
15 import time | 16 import time |
16 | |
17 try: | |
18 import selectors | |
19 | |
20 selectors.BaseSelector | |
21 except ImportError: | |
22 from .thirdparty import selectors2 as selectors | |
23 | 17 |
24 from .i18n import _ | 18 from .i18n import _ |
25 from . import ( | 19 from . import ( |
26 encoding, | 20 encoding, |
27 error, | 21 error, |
302 retval.update(res[1]) | 296 retval.update(res[1]) |
303 else: | 297 else: |
304 yield res | 298 yield res |
305 except EOFError: | 299 except EOFError: |
306 selector.unregister(key.fileobj) | 300 selector.unregister(key.fileobj) |
301 # pytype: disable=attribute-error | |
307 key.fileobj.close() | 302 key.fileobj.close() |
303 # pytype: enable=attribute-error | |
308 openpipes -= 1 | 304 openpipes -= 1 |
309 except IOError as e: | 305 except IOError as e: |
310 if e.errno == errno.EINTR: | 306 if e.errno == errno.EINTR: |
311 continue | 307 continue |
312 raise | 308 raise |