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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
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.