scikit-learn/scikit-learn — pull request #2729 by ogrisel (2014-01-08 15:15:38+00:00)
Title: [RFC] make BaseEstimator.get_params thread-safe by default

Modifying the configuration warnings filters of the Python standard library and using `warnings.catch_warnings` are unfortunately not thread-safe operations.

However our `get_params` implementation needs to record deprecation warning when introspecting estimator parameters to avoid including them in the model description rendering the `sklearn.base.clone` function thread-unsafe.

This problem has caused the recent random Jenkins failures reported in #2721 (since random forests now use threads internally when `n_jobs != 1`). The specific issue reported in #2721 has been fixed by making RF models call `clone` only in the sequential section of the code. However I think that `get_params` should be thread safe by default to avoid very confusing behaviors and other hard to debug crash to our users.

Here is a proposal to make this thread-safe by default by using a `threading.RLock`. I am not sure this is the best solution but I thought it would be more constructive to discuss this issue with a working possible solution.