Ticket #855: mysql-timeout-bcfg2-0-9-6.patch
File mysql-timeout-bcfg2-0-9-6.patch, 3.2 KB (added by somekool <[email protected]…>, 13 years ago) |
---|
-
src/lib/Server/Reports/importscript.py
1 #! 1 #!/usr/bin/env python 2 2 '''Imports statistics.xml and clients.xml files in to database backend for new statistics engine''' 3 3 __revision__ = '$Revision$' 4 4 … … 56 56 def load_stats(cdata, sdata, vlevel, quick=False, location=''): 57 57 cursor = connection.cursor() 58 58 clients = {} 59 cursor.execute("SELECT name, id from reports_client;")60 [clients.__setitem__(a, b) for a, b in cursor.fetchall()]61 59 62 60 for node in sdata.findall('Node'): 63 61 name = node.get('name') 62 cursor.execute("SELECT name, id from reports_client where name = '%s';" % (name) ) 63 [clients.__setitem__(a, b) for a, b in cursor.fetchall()] 64 64 if not clients.has_key(name): 65 65 cursor.execute(\ 66 66 "INSERT INTO reports_client VALUES (NULL, %s, %s, NULL, NULL)", … … 167 167 cursor.execute("INSERT INTO reports_performance_interaction VALUES (NULL, %s, %s);", 168 168 [item_id, current_interaction.id]) 169 169 except: 170 # WTF 170 171 pass 171 172 172 if vlevel > 1:173 print("----------------INTERACTIONS SYNCED----------------")174 cursor.execute("select reports_interaction.id, x.client_id from (select client_id, MAX(timestamp) as timer from reports_interaction Group BY client_id) x, reports_interaction where reports_interaction.client_id = x.client_id AND reports_interaction.timestamp = x.timer")175 for row in cursor.fetchall():176 cursor.execute("UPDATE reports_client SET current_interaction_id = %s where reports_client.id = %s",177 [row[0],row[1]])178 if vlevel > 1:179 print("------------LATEST INTERACTION SET----------------")180 181 173 for key in pingability.keys(): 182 174 if key not in clients: 183 175 #print "Ping Save Problem with client %s" % name -
src/lib/Component.py
71 71 self.cleanup = False 72 72 return 73 73 try: 74 # forcing django to reinitiate a new database connection for each fork() 75 from django.db import connection 76 connection.connection = None 74 77 self.send_response(200) 75 78 self.send_header("Content-type", "text/xml") 76 79 self.send_header("Content-length", str(len(response))) … … 217 220 if pid: 218 221 self.children.append(pid) 219 222 raise ForkedChild 223 # forcing django to reinitiate a new database connection for each fork() 224 from django.db import connection 225 connection.connection = None 220 226 # all handlers must take address as the first argument 221 227 response = self._dispatch(method, (address, ) + params) 222 228 # wrap response in a singleton tuple