Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1 non threading python

MySQLdb
closed
Andy Dustman
MySQLdb (53)
5
2012-09-19
2001-04-26
No

MySQL for Python version 0.3.5
Python 2.0

I have two Python versions, one compiled with thread
support and the othe without threads. The version
without threads is used in mod_python, because
compatibility issues.

When I try to use "MySQL for Python" from the non
threading version, I receive a runtime error since
"threading.Lock()" fails.

The threading autodetect in the library if fooled since
it only tries to import the module "threading".
Neveretheless, I can have a python version with that
module and NOT threading support.

The patch is fairly simple:

>>>>>
--- MySQLdb.py.old Thu Apr 26 16:42:28 2001
+++ MySQLdb.py Tue Apr 17 16:22:13 2001
@@ -27,6 +27,7 @@

try:
import threading
+ threading.Lock()
_threading = threading
del threading
except:
<<<<<

Discussion

  • Andy Dustman
    Andy Dustman
    2001-05-09

    Logged In: YES
    user_id=71372

    There's a new MySQLdb tree for 0.9.0. You can specifically
    tell it to not use threads by supplying a threads=0
    parameter to connect(). If there really is a faux threading
    module on systems without threads, I will have to rework it
    a little, but threads=0 should still work.

     
  • Andy Dustman
    Andy Dustman
    2001-05-11

    Logged In: YES
    user_id=71372

    I've taken out all the thread stuff entirely. The only time
    it was ever used is when you tried to share a connection
    between two threads. You can still use threads, just don't
    try to share them between threads unless you use a lock to
    make sure they both don't try to use the connection
    simultaneously.