theubie / complex_memory

A KoboldAI-like memory extension for oobabooga's text-generation-webui
GNU Affero General Public License v3.0
107 stars 14 forks source link

Cache error: file is locked by another process #22

Open PaulCoddington opened 1 year ago

PaulCoddington commented 1 year ago

This extension creates _pfpcharacter.png in the cache, but crashes the next time it attempts to access it because "PermissionError: [WinError 32] The process cannot access the file because it is being used by another process".

Error occurs in line 157 of script.py:

result = chat.load_character(character_menu, name1, name2, False)

PaulCoddington commented 1 year ago

Upon further investigation, this appears to be a bug in Oobabooga itself. Changes are required in 4 modules to address it:

server.py
\modules\chat.py
\modules\html_generator.py
\modules\ui_chat.py

All code that creates and deletes image files in the cache needs to be safeguarded against accidentally leaving files locked and/or be able to handle transient file locks caused by antivirus, thumbnailing, indexing, etc.

Delaying 1 second and trying again, for 3 attempts, is sufficient to solve the issue.