Handling locked db tables...
- From: breal <hacker.stevenson@xxxxxxxxx>
- Date: Wed, 20 Feb 2008 07:24:28 -0800 (PST)
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.
.
- Follow-Ups:
- Re: Handling locked db tables...
- From: M.-A. Lemburg
- Re: Handling locked db tables...
- Prev by Date: Re: smtplib & gnupg
- Next by Date: Re: Handling locked db tables...
- Previous by thread: smtplib & gnupg
- Next by thread: Re: Handling locked db tables...
- Index(es):
Relevant Pages
|