File: test_garbage_collect.py

package info (click to toggle)
python-parsl 2025.12.01%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,112 kB
  • sloc: python: 24,369; makefile: 352; sh: 252; ansic: 45
file content (30 lines) | stat: -rw-r--r-- 779 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import threading
import time

import pytest

import parsl
from parsl.app.app import python_app
from parsl.tests.configs.local_threads import fresh_config as local_config


@python_app
def slow_double(x, may_continue: threading.Event):
    may_continue.wait()
    return x * 2


@pytest.mark.local
def test_garbage_collect():
    """ Launches an app with a dependency and waits till it's done and asserts that
    the internal refs were wiped
    """
    evt = threading.Event()
    x = slow_double(10, evt)
    x = slow_double(x, evt)

    assert parsl.dfk().tasks[x.tid]['app_fu'] == x, "Tasks table should have app_fu ref before done"

    evt.set()
    assert x.result() == 10 * 4
    assert x.tid not in parsl.dfk().tasks, "Task record should be wiped after task completion"