V1.5 randomly hangs on import

### Describe the bug

Since upgrading to version 1.5.0 we are seeing issues where the process stalls on import. Through a core dump, it appears to be locking up [here](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/__init__.py#L154). We run hundreds of processes in parallel and it will hang on only a handful (less than 10).

### Steps/Code to Reproduce

```
import sklearn
```

### Expected Results

it imports

### Actual Results

process hangs indefinitely.

### Versions

```shell
System:
    python: 3.11.3 (main, May 15 2023, 15:45:52) [GCC 11.2.0]
executable: /home/jcoder/git/neo/neo/pyenv/bin/python
   machine: Linux-6.1.87-x86_64-with-glibc2.31

Python dependencies:
      sklearn: 1.5.0
          pip: 24.0
   setuptools: 70.0.0
        numpy: 1.24.4
        scipy: 1.11.1
       Cython: 0.29.35
       pandas: 2.0.2
   matplotlib: 3.7.2
       joblib: 1.3.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /opt/anaconda/2023/envs/pandas2/lib/libopenblasp-r0.3.23.so
        version: 0.3.23
threading_layer: pthreads
   architecture: Zen
    num_threads: 64

       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /home/~~~~~~/lib/python3.11/site-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
        version: None
    num_threads: 64
```

COMMENT:
Thanks @jeremiedbb, if I understand this correctly, we have a deadlock. 
Seems thread 1 (LWP 200) thinks 204 is the owner and thread 3 (LWP 204) thinks 200 is owner.
``` 
#1  0x00007f11892c6131 in __GI___pthread_mutex_lock (mutex=0x7f1189312968 <_rtld_global+2312>) at ../nptl/pthread_mutex_lock.c:115
115     ../nptl/pthread_mutex_lock.c: No such file or directory.
(gdb) print mutex.__data.__owner
$1 = 204
(gdb) threads
Undefined command: "threads".  Try "help".
(gdb) info threads
  Id   Target Id                                         Frame
* 1    Thread 0x7f1188f6e280 (LWP 200) "python"          0x00007f11892c6131 in __GI___pthread_mutex_lock (mutex=0x7f1189312968 <_rtld_global+2312>) at ../nptl/pthread_mutex_lock.c:115
  2    Thread 0x7f117e7ff700 (LWP 202) "jemalloc_bg_thd" futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7f117ee16630) at ../sysdeps/nptl/futex-internal.h:183
  3    Thread 0x7f1171509700 (LWP 204) "python"          __lll_lock_wait (futex=futex@entry=0x7f1189312990 <_rtld_global+2352>, private=0) at lowlevellock.c:52
(gdb) thread 3
[Switching to thread 3 (Thread 0x7f1171509700 (LWP 204))]
(gdb) up
#1  0x00007f11892c6131 in __GI___pthread_mutex_lock (mutex=0x7f1189312990 <_rtld_global+2352>) at ../nptl/pthread_mutex_lock.c:115
115     ../nptl/pthread_mutex_lock.c: No such file or directory.
(gdb) print mutex.__data.__owner
$2 = 200
```
based on `pystack` output, pid 200 is stuck importing `sklearn`
``` 
    (Python) File "/home/jcoder/git/neo/neo/pyenv/lib/python3.11/site-packages/sklearn/__init__.py", line 157, in <module>
        _threadpool_controller = ThreadpoolController()
    (Python) File "/home/jcoder/git/neo/neo/pyenv/lib/python3.11/site-packages/threadpoolctl.py", line 818, in __init__
        self._load_libraries()
    (Python) File "/home/jcoder/git/neo/neo/pyenv/lib/python3.11/site-packages/threadpoolctl.py", line 976, in _load_libraries
        self._find_libraries_with_dl_iterate_phdr()
    (Python) File "/home/jcoder/git/neo/neo/pyenv/lib/python3.11/site-packages/threadpoolctl.py", line 1017, in _find_libraries_with_dl_iterate_phdr
        libc.dl_iterate_phdr(c_match_library_callback, data)
    (Python) File "/home/jcoder/git/neo/neo/pyenv/lib/python3.11/site-packages/threadpoolctl.py", line 1005, in match_library_callback
        self._make_controller_from_path(filepath)
    (Python) File "/home/jcoder/git/neo/neo/pyenv/lib/python3.11/site-packages/threadpoolctl.py", line 1175, in _make_controller_from_path
        lib_controller = controller_class(

    (Python) File "/home/jcoder/git/neo/neo/pyenv/lib/python3.11/site-packages/threadpoolctl.py", line 114, in __init__
        self.dynlib = ctypes.CDLL(filepath, mode=_RTLD_NOLOAD)
    (Python) File "/opt/anaconda/2023/envs/pandas2/lib/python3.11/ctypes/__init__.py", line 376, in __init__
        self._handle = _dlopen(self._name, mode)

```
while 204 is stuck in New Relic code.
```
    (Python) File "/opt/anaconda/2023/envs/pandas2/lib/python3.11/site-packages/newrelic/packages/urllib3/util/connection.py", line 72, in create_connection
        for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
    (Python) File "/opt/anaconda/2023/envs/pandas2/lib/python3.11/socket.py", line 962, in getaddrinfo
        for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
```

The New Relic code is using `threading.Thread()`, so I'm not sure if that is the `fork` issue mentioned, or something different. Since it clearly seems to be an issue with new relic, though, I'll get in contact with our support folks there.

Labels: Bug, Needs Reproducible Code