]> git.proxmox.com Git - mirror_qemu.git/commit - python/qemu/qmp/legacy.py
python/aqmp: add __del__ method to legacy interface
authorJohn Snow <jsnow@redhat.com>
Mon, 10 Jan 2022 23:28:45 +0000 (18:28 -0500)
committerJohn Snow <jsnow@redhat.com>
Fri, 21 Jan 2022 21:01:31 +0000 (16:01 -0500)
commit3bc72e3aed76e0326703db81964b13f1da075cbf
tree623f11171a3b18e8f5aa545a6ef18a2aeb3b7d2e
parentdc6877bd2ea04a38700adcea2359d5d20c1082a6
python/aqmp: add __del__ method to legacy interface

asyncio can complain *very* loudly if you forget to back out of things
gracefully before the garbage collector starts destroying objects that
contain live references to asyncio Tasks.

The usual fix is just to remember to call aqmp.disconnect(), but for the
sake of the legacy wrapper and quick, one-off scripts where a graceful
shutdown is not necessarily of paramount imporance, add a courtesy
cleanup that will trigger prior to seeing screenfuls of confusing
asyncio tracebacks.

Note that we can't *always* save you from yourself; depending on when
the GC runs, you might just seriously be out of luck. The best we can do
in this case is to gently remind you to clean up after yourself.

(Still much better than multiple pages of incomprehensible python
warnings for the crime of forgetting to put your toys away.)

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Beraldo Leal <bleal@redhat.com>
python/qemu/aqmp/legacy.py