In reviewing my comments on Jacob, I understand that the culprit is this line (not published)
d = self._rooms self._rooms = d.clear()
d.clear() will clear the d (and self._rooms ) self._rooms and return None . Thus, everything said is done, d is an empty dictionary, and self._rooms is None .
The cleanest solution for this:
self._rooms.clear() #No need for assignment here!
moreover, self._rooms seems to be inherited from dict - so it may have other attributes that you don't want to lose:
self._rooms={}
mgilson
source share