Question about pickle
Phu Sam
psam1304 at gmail.com
Fri Jun 21 19:54:53 EDT 2013
I have a method that opens a file, lock it, pickle.load the file into a
dictionary.
I then modify the status of a record, then pickle.dump the dictionary back
to the file.
The problem is that the pickle.dump never works. The file never gets
updated.
def updateStatus(self, fp, stn, status):
f = open(fp, 'rw+')
fcntl.flock(f.fileno(),fcntl.LOCK_EX | fcntl.LOCK_NB)
tb = pickle.load(f)
self.modifyDict(tb, stn, status)
pickle.dump(tb, f)
fcntl.flock(f.fileno(),fcntl.LOCK_UN)
f.close()
What could be the problem here?
What mode should I use to open the file to allow both pickle.load and
pickle.dump?
Thanks,
Phu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130621/10506980/attachment.html>
More information about the Python-list
mailing list