equal
deleted
inserted
replaced
71 """rollback the current transaction for this user""" |
71 """rollback the current transaction for this user""" |
72 for source, cnx in self.source_cnxs.values(): |
72 for source, cnx in self.source_cnxs.values(): |
73 # catch exceptions, rollback other sources anyway |
73 # catch exceptions, rollback other sources anyway |
74 try: |
74 try: |
75 cnx.rollback() |
75 cnx.rollback() |
76 except: |
76 except Exception: |
77 source.critical('rollback error', exc_info=sys.exc_info()) |
77 source.critical('rollback error', exc_info=sys.exc_info()) |
78 # error on rollback, the connection is much probably in a really |
78 # error on rollback, the connection is much probably in a really |
79 # bad state. Replace it by a new one. |
79 # bad state. Replace it by a new one. |
80 self.reconnect(source) |
80 self.reconnect(source) |
81 |
81 |
84 if i_know_what_i_do is not True: # unexpected closing safety belt |
84 if i_know_what_i_do is not True: # unexpected closing safety belt |
85 raise RuntimeError('connections set shouldn\'t be closed') |
85 raise RuntimeError('connections set shouldn\'t be closed') |
86 for cu in self._cursors.values(): |
86 for cu in self._cursors.values(): |
87 try: |
87 try: |
88 cu.close() |
88 cu.close() |
89 except: |
89 except Exception: |
90 continue |
90 continue |
91 for _, cnx in self.source_cnxs.values(): |
91 for _, cnx in self.source_cnxs.values(): |
92 try: |
92 try: |
93 cnx.close() |
93 cnx.close() |
94 except: |
94 except Exception: |
95 continue |
95 continue |
96 |
96 |
97 # internals ############################################################### |
97 # internals ############################################################### |
98 |
98 |
99 def cnxset_set(self): |
99 def cnxset_set(self): |
133 sources = (source,) |
133 sources = (source,) |
134 for source in sources: |
134 for source in sources: |
135 try: |
135 try: |
136 # properly close existing connection if any |
136 # properly close existing connection if any |
137 self.source_cnxs[source.uri][1].close() |
137 self.source_cnxs[source.uri][1].close() |
138 except: |
138 except Exception: |
139 pass |
139 pass |
140 source.info('trying to reconnect') |
140 source.info('trying to reconnect') |
141 self.source_cnxs[source.uri] = (source, source.get_connection()) |
141 self.source_cnxs[source.uri] = (source, source.get_connection()) |
142 self._cursors.pop(source.uri, None) |
142 self._cursors.pop(source.uri, None) |
143 |
143 |