Menu

Do I need to enable thread safe mysql lib?

Help
John Speno
2002-10-18
2012-09-19
  • John Speno

    John Speno - 2002-10-18

    I'm going to write a python app which uses threads (subclassing threading.Thread) and also uses MySQLdb. One python thread will only read from the DB, while another will be doing reads and writes to the DB.

    Do I need to set thread_safe_library = yes in MySQLdb' s setup.py for this?

    Thanks.

     
    • Rob Steele

      Rob Steele - 2002-10-18

      Yup.  You also need to either synchronize the reading and writing threads so that only one can get at the database at a time or else open a second connection.  You should probably use sepearate connections, one for each thread.

      Rob

       
    • John Speno

      John Speno - 2002-10-18

      Thanks Rob. I've recompiled my MySQLdb using threads, and I'll also use two connections.

      Once a record has been read by the first thread, the second thread may or may not change the record, but nothing (in this program at least) will be touching the database between when those things happen.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.