diff --git a/Classes/PluginConf.py b/Classes/PluginConf.py index d34a86c45..475cc574d 100644 --- a/Classes/PluginConf.py +++ b/Classes/PluginConf.py @@ -318,7 +318,7 @@ "ThreadWriter": {"type": "bool","default": 0,"current": None,"restart": 0,"hidden": False,"Advanced": True,}, "ThreadCommunication": {"type": "bool","default": 0,"current": None,"restart": 0,"hidden": False,"Advanced": True,}, "ZLinky": {"type": "bool","default": 0,"current": None,"restart": 0,"hidden": False,"Advanced": True,}, - "Garbage": {"type": "bool","default": 0,"current": None,"restart": 0,"hidden": False,"Advanced": True,}, + "Garbage": {"type": "bool","default": 0,"current": None,"restart": 0,"hidden": True,"Advanced": True,}, }, }, # Others diff --git a/plugin.py b/plugin.py index a912353c0..ad99d8c5f 100644 --- a/plugin.py +++ b/plugin.py @@ -275,9 +275,7 @@ def __init__(self): def onStart(self): Domoticz.Status( "Zigbee for Domoticz plugin starting") - # Enable the cycle detector - # gc.set_debug(gc.DEBUG_SAVEALL) - + _current_python_version_major = sys.version_info.major _current_python_version_minor = sys.version_info.minor @@ -367,6 +365,11 @@ def onStart(self): self.zigbee_communication, self.VersionNewFashion, self.DomoticzMajor, self.DomoticzMinor, Parameters["HomeFolder"], self.HardwareID ) + if self.pluginconf.pluginConf["Garbage"]: + # Enable the cycle detector + Domoticz.Log("Setup Garbage set_debug to %s" %gc.DEBUG_LEAK) + gc.set_debug(gc.DEBUG_LEAK) + # Create Domoticz Sub menu if "DomoticzCustomMenu" in self.pluginconf.pluginConf and self.pluginconf.pluginConf["DomoticzCustomMenu"] : install_Z4D_to_domoticz_custom_ui( ) @@ -431,7 +434,7 @@ def onStart(self): self.zigbee_communication and self.zigbee_communication == "zigpy" and ( self.pluginconf.pluginConf["forceZigpy_noasyncio"] or self.domoticzdb_Hardware.multiinstances_z4d_plugin_instance()) - ): + ): # https://github.com/python/cpython/issues/91375 self.log.logging("Plugin", "Status", "Multi instances plugin detected. Enable zigpy workaround") sys.modules["_asyncio"] = None @@ -512,7 +515,6 @@ def onStart(self): if "Model" in self.ListOfDevices[x] and self.ListOfDevices[x]["Model"] in ( "", {} ): profalux_fake_deviceModel(self, x) - self.log.logging("Plugin", "Debug", "ListOfDevices after checkListOfDevice2Devices: " + str(self.ListOfDevices)) self.log.logging("Plugin", "Debug", "IEEE2NWK after checkListOfDevice2Devices : " + str(self.IEEE2NWK)) @@ -733,12 +735,17 @@ def onStop(self): # sourcery skip: class-extract-method if self.adminWidgets: self.adminWidgets.updateStatusWidget(Devices, "No Communication") - # objects = gc.get_objects() - # Domoticz.Log( "Garbage Collected objects: %s" %str(objects)) + if self.pluginconf.pluginConf["Garbage"]: + + # Domoticz.Log( "Garbage Collected objects:") + # objects = gc.get_objects() + # for item in objects: + # Domoticz.Log( "- %s" %str(item)) - # Print detected cycles (garbage collectors) - # for item in gc.garbage: - # Domoticz.Log(item) + # Print detected cycles (garbage collectors) + Domoticz.Log( "Garbage Collected detected cycles:") + for item in gc.garbage: + Domoticz.Log("- %s" %str(item)) @@ -1679,8 +1686,8 @@ def do_python_garbage_collection( self ): # Garbage collector ( experimental for now) if self.internalHB % (3600 // HEARTBEAT) == 0: self.log.logging("Garbage", "Debug", "Garbage Collection status: %s" % str(gc.get_count()) ) - # self.log.logging("Garbage", "Debug", "Garbage Collection triggered: %s" % str(gc.collect()) ) self.log.logging("Garbage", "Debug", "Garbage collection statistics: %s" % str( gc.get_stats()) ) + # self.log.logging("Garbage", "Debug", "Garbage Collection triggered: %s" % str(gc.collect()) ) def _check_if_busy(self): busy_ = self.ControllerLink.loadTransmit() >= MAX_FOR_ZIGATE_BUZY