ich bin gerade ein bisschen am programmieren und hab das Problem, dass sich mein Programm immer aufgrund des locks aufhängt. Leider weiß ich nicht wie ich dort lock umgehen kann oder habe ich einen Fehler, dass es nicht funktioniert?
Code: Alles auswählen
lock = thread.allocate_lock()
actions = Queue.Queue()
threading = True
def write(value,start, al=False):
lock.acquire() #HIER HÄNGT ES
if threading == True and al == False:
actions.put((0,value,start))
lock.release()
elif threading == False or al == True:
lock.release()
fobj = open(datei, "rb+")
fobj.seek(start, 0)
fobj.write(value)
fobj.close()
def foo():
while True:
lock.acquire()
if threading == False:
if actions.empty():
break
art, data, start = actions.get()
lock.release()
if art == 0:
write(data, start, True)
elif art == 1:
truncate(start, True) #Egal
thread.start_new_thread(foo, ())
write("test", 0)