Changeset 1379
- Timestamp:
- 02/22/07 09:22:46 (6 years ago)
- File:
-
- 1 edited
-
ccsd/trunk/crcnetd/_utils/ccsd_session.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ccsd/trunk/crcnetd/_utils/ccsd_session.py
r1358 r1379 78 78 self.mode = mode 79 79 self.lock = threading.RLock() 80 80 self.db = None 81 81 82 # Session Time Records 82 83 if initiated == -1: … … 95 96 self.token = token 96 97 97 # Setup a database connection 98 self.db = PgSQL.connect(host=self.dhost, database=self.database, \ 99 user=self.duser, password=self.dpass) 98 # Setup a database connection 99 self._connect() 100 100 101 101 # Setup session in the database … … 133 133 (self.session_id, self.username, self.mode)) 134 134 135 def _connect(self): 136 # Close the existing connection 137 if self.db is not None: 138 try: 139 self.db.close() 140 except: 141 log_warn("Could not close existing db connection cleanly " \ 142 "in session #%s" % self.session_id, sys.exc_info()) 143 144 # Setup a database connection 145 self.db = PgSQL.connect(host=self.dhost, database=self.database, \ 146 user=self.duser, password=self.dpass) 147 135 148 def getSessionObject(self): 136 149 """Returns a dictionary containing information about the session""" … … 351 364 except: 352 365 log_error("Unable to obtain cursor for query!", sys.exc_info()) 366 # This pretty much means our db connection is hosed, reconnect 367 self._connect() 353 368 self.lock.release() 354 369 raise ccsd_session_error("Unable to obtain cursor for query!") … … 448 463 commit = 1 449 464 465 # Obtain a cursor 466 try: 467 cursor = self.db.cursor() 468 except: 469 # This pretty much means our db connection is hosed, reconnect 470 self._connect() 471 log_error("Could not obtain cursor for execute", sys.exc_info()) 472 self.lock.release() 473 raise ccsd_session_error("Could not obtain cursor") 474 450 475 # Execute the query 451 476 try: 452 cursor = self.db.cursor()453 477 res = cursor.execute(sql, params) 454 478 except: … … 634 658 635 659 # Setup a database connection 636 self.db = PgSQL.connect(host=self.dhost, database=self.database, \ 637 user=self.duser, password=self.dpass) 660 self._connect() 638 661 639 662 # Steal a session ID from the sequence, but don't put the session
Note: See TracChangeset
for help on using the changeset viewer.
