Philipp Hörist pushed to branch master at gajim / gajim


Commits:
adef2ee1 by Philipp Hörist at 2023-10-06T22:33:38+02:00
fix: Observable: Fix race condition when removing handlers

- - - - -


1 changed file:

- gajim/common/helpers.py


Changes:

=====================================
gajim/common/helpers.py
=====================================
@@ -1317,7 +1317,12 @@ def _remove(handlers: 
list[weakref.WeakMethod[types.AnyCallableT]]
 
             for handler in list(handlers):
                 func = handler()
-                if func is None or func.__self__ is obj:
+                # Don’t remove dead weakrefs from the handler list
+                # notify() will remove dead refs, and __disconnect()
+                # can be called from inside notify(), this can lead
+                # to race conditions where later notfiy tries to remove
+                # a dead ref which is not anymore in the list.
+                if func is not None and func.__self__ is obj:
                     handlers.remove(handler)
 
         if signals is None:



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/adef2ee164a2890fa9e71c1cdf0269aa4fd2a3c5

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/adef2ee164a2890fa9e71c1cdf0269aa4fd2a3c5
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to