
TODO: TODO_30_69_19_14: client hangs with infinite spinner

# Issue

So far, there were only the reasons for occurrences of this bug
when `os.fork`-ed client hangs on `import` inside `requests` library (on [`import encodings.idna`][import_encodings_idna]).

# Status

The fix for hanging on `import` is apparently resolved by
doing this import ahead of `os.fork` in the parent client process:

```py
import encodings.idna
```

This import would happen anyway (as transitive to `import requests`) after the `os.fork`,
but that is where it hangs occasionally.

The hypothesis is that it has something to do with both parent and child importing it at the same time.
Importing it ahead might avoid that concurrency - similar to [`import encodings.idna`][import_encodings_idna] there.

The issue is also alleviated with an alarm signal set before the attempt to `import` in case it happens again.
This explains the issue to the user immediately (within a second of occurrence), and the user can retry
its request rather than waiting and guessing why response takes long time.

# Workaround

If spinner is disabled (see [`show_pending_spinner`](https://github.com/argrelay/argrelay/blob/v0.7.0.final/src/argrelay/sample_conf/argrelay.client.json#L8)),
it does not happen (because another client process is not `os.fork`-ed).

But that is not a desirable solution as spinner provides feedback on requests in progress.

# Identification

When spinner hangs infinitely, press `Ctrl+C` -
it prints (interleaved) stack traces for both child and parent to identify if it is the same issue.

After filtering out interleaved lines,
stack trace from hanged [`argrelay` client version 0.7.0.final](https://github.com/argrelay/argrelay/blob/v0.7.0.final/src/argrelay/relay_client/__main__.py#L84)
using [`requests` version 2.31.0](https://github.com/psf/requests/blob/v2.31.0/requests/__init__.py#L160):
```
File "/venv/lib/python3. 11/site-packages/argrelay/relay_client/__main__.py", line 84, in main
from argrelay.relay_client.RemoteClient import RemoteClient
File "/venv/lib/python3.11/site-packages/argrelay/relay_client/RemoteClient.py”, line 2, in <module>
from argrelay.relay_client.RemoteClientCommandFactory import RemoteClientCommandFactory
File "/venv/lib/python3.11/site-packages/argrelay/relay_client/RemoteClientCommandFactory. py”, line 1, in <module>
from argrelay.client_command_remote. AbstractRemoteClientCommand import AbstractRemoteClientCommand
File "/venv/lib/python3.11/site-packages/argrelay/client_command_remote/AbstractRemoteClientCommand.py", line 4, in <module>
import requests
File "/venv/lib/python3.11/site-packages/requests/__init_.py", line 160, in <module>
from .api import delete, get, head, options, patch, post, put, request
File "/venv/lib/python3.11/site-packages/requests/api.py”, line 11, in <module>
from . import sessions
File "/venv/lib/python3.11/site-packages/requests/sessions.py”, line 15, in <module>
from .adapters import HTTPAdapter
File "/venv/lib/python3.11/site-packages/requests/adapters.py”, line 44, in <module>
from .models import Response
File "/venv/lib/python3.11/site-packages/requests/models.py”, line 13, in <module>
import encodings.idna  # noqa: F401
File "<frozen importlib._bootstrap>", line 224, in _lock_unlock_module
File “<frozen importlib._bootstrap>", line 120, in acquire
KeyboardInterrupt
```

# Failed attempt to fix it by swapping `requests` with `urllib3`

This worsened the situation (and was reverted) - `urllib3` also failed on `idna`-related import:

```
  File "/venv/1ib/python3.11/site-packages/urllib3/connection.py”, line 199, in _new_conn
    sock = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/urllib3/util/connection.py”, line 56, in create_connection
    host.encode("idna")
  File "/usr/lib/python3.11/encodings/_init_.py", Tine 99, in search_function
    mod = __import__('encodings.' + modname, fromlist=_import_tail,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File “<frozen importlib._bootstrap>", line 224, in _lock_unlock_module
  File “<frozen importlib._bootstrap>", line 120, in acquire
KeyboardInterrupt
```

But `urllib3` also hangs on `import encodings.idna` during request.
And worse - there is no simple way to separate hang via alert signal anymore.

[import_encodings_idna]: https://github.com/psf/requests/commit/d7227fbb7e07af35f23a0d370ab3b01661af9e40#commitcomment-146935826
