[Updated] D9660: worker: restrict use of worker procesess to the main thread
joerg.sonnenberger (Joerg Sonnenberger)
phabricator at mercurial-scm.org
Thu Jan 7 13:18:37 UTC 2021
joerg.sonnenberger updated this revision to Diff 24628.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9660?vs=24514&id=24628
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9660/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9660
AFFECTED FILES
mercurial/worker.py
CHANGE DETAILS
diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -67,6 +67,9 @@
if pycompat.ispy3:
+ def ismainthread():
+ return threading.current_thread() == threading.main_thread()
+
class _blockingreader(object):
def __init__(self, wrapped):
self._wrapped = wrapped
@@ -100,6 +103,9 @@
else:
+ def ismainthread():
+ return isinstance(threading.current_thread(), threading._MainThread)
+
def _blockingreader(wrapped):
return wrapped
@@ -155,6 +161,11 @@
release the GIL.
"""
enabled = ui.configbool(b'worker', b'enabled')
+ if enabled and _platformworker is _posixworker and not ismainthread():
+ # The POSIX worker has to install a handler for SIGCHLD.
+ # Python up to 3.9 only allows this in the main thread.
+ enabled = False
+
if enabled and worthwhile(ui, costperarg, len(args), threadsafe=threadsafe):
return _platformworker(ui, func, staticargs, args, hasretval)
return func(*staticargs + (args,))
To: joerg.sonnenberger, #hg-reviewers, marmoute
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210107/db593e9f/attachment-0002.html>
More information about the Mercurial-patches
mailing list