diff options
author | Thomas Haller <thaller@redhat.com> | 2022-07-13 10:04:56 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-07-13 10:05:12 +0200 |
commit | 9511ac7d20b4fdd471039d7756a912f319111c8a (patch) | |
tree | 844cea85ce4d7051f460f10a2a770d2f4594d73a | |
parent | 4655b7c308461ae1f86d592ea6d45e00a2820423 (diff) | |
download | NetworkManager-9511ac7d20b4fdd471039d7756a912f319111c8a.tar.gz |
examples: fix tracking destruction in destroy_nmc()
While iterating the context (once), multiple sources can be dispatched.
So if we get a timeout and shortly after the weak-ref callback, then
we still need to honor the weak-ref.
In particular, because weak_ref.unref() is not safe to do after
the object was already destroyed. So we need to be correct about
tracking destruction.
-rwxr-xr-x | examples/python/gi/gmaincontext.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/python/gi/gmaincontext.py b/examples/python/gi/gmaincontext.py index b7ebf78e6d..90a9fa2542 100755 --- a/examples/python/gi/gmaincontext.py +++ b/examples/python/gi/gmaincontext.py @@ -375,9 +375,9 @@ def destroy_nmc(nmc_holder): finished = [] def _weak_ref_cb(): - if not finished: - log(f"[destroy_nmc]: context busy watcher is gone") - finished.append(True) + log(f"[destroy_nmc]: context busy watcher is gone") + finished.clear() + finished.append(True) # We take a weak ref on the context-busy-watcher object and give up # our reference on nmc. This must be the last reference, which initiates |