Help with gdbm and fcntl.flock

Wayne Ringling wayne at
Mon Oct 22 00:20:19 CEST 2001

 I am trying to flock a gbdm file but I can't get it to work.  Any ideas
really appreciated :)
 I ripped out all the other stuff to just get this part working.  It's a
small script to handle ip addrs for a smallish database.  But I want to get
an exclusive lock on the database while I have it open for reading/writing
to.  I have two little projects that I need this for if we can get it to
work.  Is it possible to get a flock on a database object?

Here's a snippet from my code:

import gdbm
import fcntl

def lock(file):
	fcntl.flock(file, fcntl.LOCK_EX)

def main():
	# Open database
		dbase ="remote_addr.dbm","w",0644)
		dbase ="remote_addr.dbm","c",0644)
	# Now get exclusive flock

if __name__ == '__main__':

Also I am using Python 2.0 if that makes any diference.


More information about the Python-list mailing list