Skip to content

dask threads break filterwarnings on 3.14t #14077

@crusaderky

Description

@crusaderky

I'm a Dask maintainer and I'm currently working on 3.14t support.

My test suite runs Dask with the default threading scheduler on 3.14t.
Dask spawns a thread, logs a RuntimeWarning inside the thread, and then joins it.

On all other Python interpreters, @pytest.mark.filterwarnings successfully suppresses the warning.
On Python 3.14t, if any other test previously spawned and rejoined dask threads, the warning is not suppressed.

Reproducer

import dask.array as da
import pytest


def test_1():
    a = da.zeros(1)
    a.compute()


@pytest.mark.filterwarnings("ignore:invalid value encountered in divide:RuntimeWarning")
def test_2():
    a = da.zeros(1) / da.zeros(1)
    a.compute()

Outcome:

  • Python 3.14.2, pytest: OK
  • Python 3.14.2t, pytest -k test_2: OK
  • Python 3.14.2t, pytest:
FAILED test1.py::test_2 - RuntimeWarning: invalid value encountered in divide
  • Python 3.14.2, pytest, change compute() to compute(scheduler="sync"): OK

I've failed to further simplify the reproducer further. This works fine:

import numpy as np
import pytest
import threading
import dask.array as da

def test_1():
    a = da.zeros(1)
    a.compute()


@pytest.mark.filterwarnings("ignore:invalid value encountered in divide:RuntimeWarning")
def test2():
    t = threading.Thread(target=np.divide, args=(0, 0))
    t.start()
    t.join()

If I merge the two tests, ending up with a single test that spawns and destroys the dask thread pool twice, the issue disappears. This works fine:

import dask.array as da
import pytest


@pytest.mark.filterwarnings("ignore:invalid value encountered in divide:RuntimeWarning")
def test_1():
    a = da.zeros(1)
    a.compute()
    a = da.zeros(1) / da.zeros(1)
    a.compute()

Environment

pytest 9.0.2
numpy 2.4.0
dask 2025.12.0
Python 3.14.2

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