ChannelsLiveServerTestCase can't be run in parallel
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 826
- PR merge metrics
- No merged PRs in 30d
Description
The error:
```
$ python manage.py test --parallel
[...]
ERROR: setUpClass (tests.chat.test_chat_liveserver.ChatConsumerTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/mathieu/Library/Application Support/pypoetry/python/cpython@3.12.11/lib/python3.12/unittest/suite.py", line 166, in _handleClassSetUp
setUpClass()
File "/Users/mathieu/Library/Caches/pypoetry/virtualenvs/tarmac-server-HCLVLw_k-py3.12/lib/python3.12/site-packages/channels/testing/live.py", line 77, in setUpClass
cls._server_process.start()
^^^^^^^^^^^^^^^^^
File "/Users/mathieu/Library/Application Support/pypoetry/python/cpython@3.12.11/lib/python3.12/multiprocessing/process.py", line 118, in start
assert not _current_process._config.get('daemon'), \
^^^^^^^^^^^^^^^^^
AssertionError: daemonic processes are not allowed to have children
```
Somewhat similar to issue #1843. The "solution" - force multiprocessing start method to `fork` - was removed in #1922.
I think forcing `fork` start method can't be the solution anymore, it's discouraged on macOS, that's why it was [changed to spawn in python 3.8](https://docs.python.org/3/whatsnew/3.8.html#multiprocessing).
I *think* the right fix would be to change ChannelsLiveServerTestCase to replicate Django's LiveServerTestCase design: designed to run in a thread.
If that suits you, I can start the PR.
Easy to reproduce: just run a django test suite having a `ChannelsLiveServerTestCase` with `--parallel`.
Contributor guide
Assessment
This issue has not been assessed yet.