I thought "make sure I have the GIL, either by already having it or
Thomas Wouters wrote:
> Your idea of making this an API called a 'fork lock' or something
> sounds good (though I think it needs a better name. PyBeforeFork &
> PyAfterFork?). The subprocess module, for example, disables garbage
> collection before forking and restores it afterwards to avoid
. That type of thing could also be
> done in such a function.
> Unfortunately it's rather hard to make those functions work correctly
> with the current API -- we can't provide functions you can just use as
> arguments to pthread_atfork because the global interpreter lock is not
> re-entrant and we have no way of testing whether the current thread
> holds the GIL.