[mythtv] Python: collecting searchRecorded into list() has side effects

David Osguthorpe david.osguthorpe at gmail.com
Fri Jul 26 14:51:03 UTC 2013


On Fri, Jul 26, 2013 at 07:13:50AM -0400, Raymond Wagner wrote:
> The database object should be reused if possible, as it eliminates the need to re-read the config.xml file, and allows the use of custom connection credentials, however the database object is Brit itself a connection, it's just a reference to a shared pool of connections.  Creating new ones shouldn't inherently produce new connections.  Connections are only created when you have a bunch of open cursors.


I had a similar occurrence fall last year
- somewhere around the 0.25/0.26 upgrade I think (0.26->0.26.1?)
- a python script which loaded large number of program records started failing with too many
connections - it had worked fine prior to the upgrade

I pinned this down to the addition of the DatabaseConfig class which seemed to change how
connection instances were returned such that the equality check for connections no longer worked
as each connection to the same database returned a different id.

I added the following patch to DatabaseConfig to add an equality operator which seemed
to solve my problems (and __ne__ for consistency)

Sorry - I should have sent this as a possible patch - although I wasnt sure at the time
this is the "right" thing to do - still not sure this is correct

--- a/mythtv/bindings/python/MythTV/database.py
+++ b/mythtv/bindings/python/MythTV/database.py
@@ -873,6 +873,12 @@ class DatabaseConfig( object ):
     def __hash__(self):
         return hash(self.ident)
 
+    def __eq__(self,other):
+        return self.__hash__() == other.__hash__()
+
+    def __ne__(self,other):
+        return self.__hash__() != other.__hash__()
+
     def copy(self):
         cls = self.__class__
         obj = cls(())




More information about the mythtv-dev mailing list