mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-14 20:18:39 +00:00
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.
This commit is contained in:
parent
4655b7c308
commit
9511ac7d20
|
@ -375,9 +375,9 @@ def destroy_nmc(nmc_holder):
|
||||||
finished = []
|
finished = []
|
||||||
|
|
||||||
def _weak_ref_cb():
|
def _weak_ref_cb():
|
||||||
if not finished:
|
log(f"[destroy_nmc]: context busy watcher is gone")
|
||||||
log(f"[destroy_nmc]: context busy watcher is gone")
|
finished.clear()
|
||||||
finished.append(True)
|
finished.append(True)
|
||||||
|
|
||||||
# We take a weak ref on the context-busy-watcher object and give up
|
# 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
|
# our reference on nmc. This must be the last reference, which initiates
|
||||||
|
|
Loading…
Reference in a new issue