I have a db table that holds a list of ports.  There is a column
in_use that is used as a flag for whether the port is currently in
use.  When choosing a port the table is read and the first available
port with in_use = 0 is used, updated to in_use = 1, used, then
updated to in_use = 0.  I am using MySQLdb and want to make sure I am
locking the table when doing reads, writes, updates since there will
be several instances of my program looking for available ports
simultaneously.

When I run a "lock table mytable read" I can do all of my
transactions.  But, when another cursor then tries to do the read I
get an error unless the first process has been completed... unlocking
the tables.  How is this handled generally?

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

Reply via email to