Noob thread lock question

Astley Le Jasper astley.lejasper at gmail.com
Thu Dec 3 09:20:29 EST 2009


When you say don't forget about the GIL, what should I not be
forgetting? I'm using sqlite and the following:

<<<<<<<<<<<<<<<code>>>>>>>>>>>>>>>>>>>>>>>>>>

thread_lock = threading.RLock()

def db_execute(sql):

    thread_lock.acquire()

    try:
        connection = sqlite3.connect(database_name)
        cursor = connection.cursor()
        cursor.execute(sql)
        connection.commit()
    except:
        log.error(formatExceptionInfo())
    finally:
        thread_lock.release()

<<<<<<<<<<<<<<<code>>>>>>>>>>>>>>>>>>>>>>>>>>



More information about the Python-list mailing list