The file may be simultaneously read and written by Python. Is there a simpler way instead of using lock?
class datamanager:
def __init__(self, filename = 'filelock'):
....
def write(self, data, isInit = False):
....
def read(self):
....
Have a look at this .
Also, the lock is needed only in the write method, as the read method doesn't modify the file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.