Annotations shouldn't leak between threads. See https://github.com/dask/dask/issues/10340.
()
| 212 | |
| 213 | |
| 214 | def test_annotations_leak(): |
| 215 | """Annotations shouldn't leak between threads. |
| 216 | See https://github.com/dask/dask/issues/10340.""" |
| 217 | b1 = threading.Barrier(2) |
| 218 | b2 = threading.Barrier(2) |
| 219 | |
| 220 | def f(n): |
| 221 | with dask.annotate(foo=n): |
| 222 | b1.wait() |
| 223 | out = dask.get_annotations() |
| 224 | b2.wait() |
| 225 | return out |
| 226 | |
| 227 | with ThreadPoolExecutor(2) as ex: |
| 228 | f1 = ex.submit(f, 1) |
| 229 | f2 = ex.submit(f, 2) |
| 230 | result = [f1.result(), f2.result()] |
| 231 | assert result == [{"foo": 1}, {"foo": 2}] |
| 232 | |
| 233 | |
| 234 | @pytest.mark.parametrize("flat", [True, False]) |