[mod_python] Error with the req.register_cleanup

David YEUNG dyeung at ust.hk
Wed Jan 3 13:47:56 EST 2001


Is there any code example how to use the 'req.register_cleanup()'?
I tried to put a function to disconnect the database through the
req.register_cleanup as following:


def index(req):
  ...
  db = MySQLdb.connect(...)
  cur = db.cursor()
  req.register_cleanup(disconnectdb,cur)
  ...
  ... some db query

def disconnectdb(cur):
  db = cur.connection
  cur.close()
  db.close()

  
The apache error_log file keeps displaying the following errors whenever
I invoke the 'register_cleanup' methods. If I do not use the 'register_cleanup',
but call the 'disconnectdb' at the end of the 'index' function. There is no
error in the log file.

---- error_log ----
[Tue Jan  2 21:32:28 2001] [notice] child pid 31239 exit signal Aborted (6)
Fatal Python error: PyThreadState_Get: no current thread
[Tue Jan  2 21:32:40 2001] [notice] child pid 31238 exit signal Aborted (6)
Fatal Python error: PyThreadState_Get: no current thread
[Tue Jan  2 21:32:46 2001] [notice] child pid 31241 exit signal Aborted (6)
Fatal Python error: PyThreadState_Get: no current thread 


I am using Apache 1.3.14 on RedHat 6.2, mod_python 2.7.1, MySQLdb 0.3.0.

Thanks for any advice.


David Yeung



More information about the Mod_python mailing list