Thread safety
thomas_benda at selinc.com
thomas_benda at selinc.com
Mon Nov 11 21:01:32 UTC 2013
I think your question was more about race conditions, transactional
stability and so forth, but it's worth noting that since the worker.py
code modifications in changeset 047110c0e2a8, Mercurial is no longer safe
to run as a Python thread.
This is due to the worker tasks attempting to ignore SIGINT in forks using
signal.signal, which is legal only in the main thread.
Oblig. Python docs quote:
"When threads are enabled, this function can only be called from the main
thread; attempting to call it from other threads will cause a ValueError
exception to be raised."
dispatch.py does something similar, but will handle the ValueError (in
_runcatch) from this (by suppressing it.)
From: Mads Kiilerich <mads at kiilerich.com>
To: mercurial-devel <mercurial-devel at selenic.com>
Date: 2013/11/06 11:46 AM
Subject: Thread safety
Sent by: mercurial-devel-bounces at selenic.com
How safe/unsafe do you think it is to run Mercurial in a multi threaded
app?
Especially, how dangerous / efficient is it really to run hgweb multi
threaded? Is it really necessary to run multiple "threads" as separate
processes?
http://selenic.com/pipermail/mercurial/2009-May/026069.html says:
> - you can't have multiple threads working on the same objects
> (repository, dirstate, context, revlog)
> - there are a couple global variables such as encoding mode
>
> These shouldn't be much of an issue. For instance, you can create
> multiple repo objects pointing to the same repo on disk and they will
> use locking appropriately.
>
> However, there may be bugs lurking as this is definitely not the
> standard mode of operation.
Largefiles do horrible things such as monkey patching modules and
classes on runtime. That is however only(?) at the command level and for
operations touching the working directory. The server and store parts
seems better.
Can anyone add more to how tread safe Mercurial is? Are you aware of
other problems or have you tried it and found that there is no problems?
/Mads
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel at selenic.com
http://selenic.com/mailman/listinfo/mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20131111/32b858a1/attachment-0002.html>
More information about the Mercurial-devel
mailing list