import fcntl import os def index(req): file = open(os.path.join(os.path.dirname(req.filename), "files/malli.txt") , "r") fcntl.flock(file.fileno(), fcntl.LOCK_SH ) tiedot = [] for i in file: rivi = i tiedot.append( rivi.split("|") ) # for j in range(0, len(lista) ): # req.write( str(lista[j]) + "\n" ) file.close() req.write( str(tiedot) + "\n" ) file = open(os.path.join(os.path.dirname(req.filename), "files/malli.txt") , "w") fcntl.flock(file.fileno(), fcntl.LOCK_EX) for i in tiedot: file.write( i[0] + "|" + i[1] + "|" + i[2] ) req.write(str( i ) + "\n") file.close() # file.close()