On 12/3/2009 6:33 AM, Astley Le Jasper wrote:
I have a number of threads that write to a database. I have created a
thread lock, but my question is this:

- If one thread hits a lock, do a) all the other threads stop, or b)
just the ones that come to the same lock?

Just the ones the comes to the same lock, but...

Though it should not be a problem since your threads are I/O bound, don't forget about the GIL (Global Interpeter Lock). A decent DB API should release the GIL when writing/reading.

- I presume that the answer is b. In which case do the threads stop
only if they come to the same instance of a lock. For example, you
could have a lock instance for one database and another instance for
another database (first_db_thread_lock = threading.RLock() ....
second_db_thread_lock = threading.RLock()).

I appreciate this is a bit of a noob question, but I didn't want to
assume anything.

ALJ

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to