scripts/qmp-shell: Use context manager instead of atexit
commitd1d14e59895b2ebd2953e9442225ffba56f80e9b
authorJohn Snow <jsnow@redhat.com>
Mon, 7 Jun 2021 20:06:38 +0000 (7 16:06 -0400)
committerJohn Snow <jsnow@redhat.com>
Fri, 18 Jun 2021 20:10:07 +0000 (18 16:10 -0400)
treea5c4f18078a3a171802094f5195c7343b921b48f
parenteac8aabc92f80d9a41d9f01163921472e309334c
scripts/qmp-shell: Use context manager instead of atexit

We can invoke the shell history writing when we leave the QMPShell scope
instead of relying on atexit. Doing so may be preferable to avoid global
state being registered from within a class instead of from the
application logic directly.

Use QMP's context manager to hook this history saving at close time,
which gets invoked when we leave the context block.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-32-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
scripts/qmp/qmp-shell