From 006ba306f7faa707ce1e55087e890b779ed024b7 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sun, 29 Jan 2012 12:07:39 -0500 Subject: [PATCH] connection: tick() isn't reentrant, lock it We can get weird keyerrors sometimes, if the global tick thread is scheduled off while a synchronous tick call is run (like after we create a vm). Eventually we will do away with manual tick() invocations but this will do for now. --- src/virtManager/connection.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/virtManager/connection.py b/src/virtManager/connection.py index 881df0115..bf5ab4569 100644 --- a/src/virtManager/connection.py +++ b/src/virtManager/connection.py @@ -94,6 +94,7 @@ class vmmConnection(vmmGObject): self.state = self.STATE_DISCONNECTED self.connectThread = None self.connectError = None + self._ticklock = threading.Lock() self.vmm = None self._caps = None @@ -1462,6 +1463,13 @@ class vmmConnection(vmmGObject): return (new, origlist, current) def tick(self, noStatsUpdate=False): + try: + self._ticklock.acquire() + self._tick(noStatsUpdate) + finally: + self._ticklock.release() + + def _tick(self, noStatsUpdate=False): """ main update function: polls for new objects, updates stats, ...""" if self.state != self.STATE_ACTIVE: return