Skip to content

ChannelsLiveServerTestCase can't be run in parallel #2181

@deronnax

Description

@deronnax

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/[email protected]/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/[email protected]/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.
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions