71b71425d3
SingleInstanceTask has distinct steps for creation of the object, and starting the task. If a different coroutine is waiting on the SingleInstanceTask, it isn't safe to directly call SingleInstanceTask.wait() as the task may or may not have been created yet. Existing code usage of SingleInstanceTask is in 4 categories, with reguards to SingleInstanceTask.wait(): 1) using SingleInstanceTask without using SingleInstanceTask.wait(). This is unchanged. 2) using SingleInstanceTask.wait without a check on task is not None. This may be safe now, but is fragile in the face of innocent-looking refactors around the SingleInstanceTask. 3) using SingleInstanceTask.wait after confirming that the task is not None. This is fine but a leaky abstraction. 4) directly waiting on the SingleInstanceTask.task. Another leaky abstraction, but it's solving a cancellation problem. Leaving this alone. By enhancing SingleInstanceTask.wait(), cases 2 and 3 are improved. The code not checking the task today is made safer, and the code checking the task today can be simplified. |
||
---|---|---|
.. | ||
__init__.py | ||
mocks.py | ||
parameterized.py | ||
test_async_helpers.py | ||
test_file_util.py | ||
test_lsb_release.py | ||
test_netplan.py | ||
test_prober.py | ||
test_pubsub.py | ||
test_utils.py | ||
test_view.py | ||
util.py |