[PATCH 3 of 4 V2] chgcache: implement the background preloading thread
Jun Wu
quark at fb.com
Thu Mar 2 16:32:23 EST 2017
Excerpts from Yuya Nishihara's message of 2017-03-03 00:51:12 +0900:
> I hope so, but googling "fork thread" or "fork thread python" made me feel
> bad. I haven't read them carefully, but they seemed to say "don't do it."
Good catch!
I had a look at CPython source code. The most related function is
PyOS_AfterFork(void), which will be executed by the child. It does not
handle all lock issues (like malloc() in libc).
I think we can use os.fork() in master and avoid threading to solve the
issue:
worker master forked master
| send(repopath) -> |
| fork() -----> |
| preload()
| replace master's socket
| connect() ----------------------> |
This solves other problems - like parsers.c has some slow functions that may
block accept().
More information about the Mercurial-devel
mailing list