#6863·streamlink

tests: flaky HLS tests, log records bleeding into subsequent tests

Author: bastimeyerCreated Mar 16, 2026Updated Sep 28, 2026
Labelsbugstream: HLStestsstream: segmented

A random test failure last night in the scheduled test runs on Windows running Python 3.13: https://github.com/streamlink/streamlink/actions/runs/23123302912/job/67161327851#step:7:392

The failed test doesn't run any segmented streams and has its own FakeStream implementation, which is totally unrelated to the failure.

The captured log records were coming from a previous test that despite our best efforts of closing all spawned threads at the end of each test run still had some segmented stream threads running. Considering the test execution order, it's likely that it's caused by the Twitch plugin's HLS integration tests, but I'm not fully sure. These tests should always close all of its spawned threads, just like the regular HLS tests that read stream data. There's nothing special here. It's possible that it's one of the other HLS / segmented stream tests that doesn't do proper cleanup for some reason.

================================== FAILURES ===================================
_________ TestPlayerOutput.test_player_close[Acceptable error: EPIPE] _________
  + Exception Group Traceback (most recent call last):
  |   File "C:\hostedtoolcache\windows\Python\3.13.12\x64\Lib\site-packages\trio\_core\_run.py", line 1126, in __aexit__
  |     raise combined_error_from_nursery
  | ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "C:\hostedtoolcache\windows\Python\3.13.12\x64\Lib\site-packages\pytest_trio\plugin.py", line 195, in _fixture_manager
    |     yield nursery_fixture
    |   File "C:\hostedtoolcache\windows\Python\3.13.12\x64\Lib\site-packages\pytest_trio\plugin.py", line 250, in run
    |     await self._func(**resolved_kwargs)
    |   File "D:\a\streamlink\streamlink\tests\cli\test_streamrunner.py", line 354, in test_player_close
    |     assert [(record.module, record.levelname, record.message) for record in caplog.records] == [
    |     ...<2 lines>...
    |     ]
    | AssertionError: assert [('segmented'...tream ended')] == [('streamrunn...tream ended')]
    |   
    |   At index 0 diff: ('segmented', 'debug', 'Closing worker thread') != ('streamrunner', 'info', 'Player closed')
    |   Left contains 2 more items, first extra item: ('streamrunner', 'info', 'Player closed')
    |   
    |   Full diff:
    |     [
    |   +     (
    |   +         'segmented',
    |   +         'debug',
    |   +         'Closing worker thread',
    |   +     ),
    |   +     (
    |   +         'segmented',
    |   +         'debug',
    |   +         'Closing writer thread',
    |   +     ),
    |         (
    |             'streamrunner',
    |             'info',
    |             'Player closed',
    |         ),
    |         (
    |             'streamrunner',
    |             'info',
    |             'Stream ended',
    |         ),
    |     ]
    +------------------------------------
----------------------------- Captured log setup ------------------------------
debug    streamlink.cli.output:player.py:326 Opening subprocess: ['mocked', '-']
------------------------------ Captured log call ------------------------------
debug    streamlink.stream.segmented:segmented.py:215 Closing worker thread
debug    streamlink.stream.segmented:segmented.py:91 Closing writer thread
info     streamlink.cli:streamrunner.py:60 Player closed
info     streamlink.cli:streamrunner.py:147 Stream ended