f361828f37
Since Python 3.11, `FileLock` is thread-local by default, which causes numerous issues with Rare because of numerous operations running in `QThreads` and `QRunnables`. To work around it, add a monkey LGDLFS class that uses a non-thread-local instance of `FileLock`. Since the monkey class exists, implement a `unlock_installed` method for code clarity * Add decorate `LegendaryCore.egl_sync` with `unlock_installed` * Log that Rare's monkeys are in use * Add function signature protocols based on `typing.Protocol`
15 lines
569 B
Python
15 lines
569 B
Python
import os
|
|
|
|
from filelock import FileLock
|
|
from legendary.lfs.lgndry import LGDLFS as LGDLFSReal
|
|
|
|
|
|
class LGDLFS(LGDLFSReal):
|
|
def __init__(self, *args, **kwargs):
|
|
super(LGDLFS, self).__init__(*args, **kwargs)
|
|
self.log.info("Using Rare's LGDLFS monkey")
|
|
# Rare: Default FileLock in Python 3.11 is thread-local, so replace it with a non-local verison
|
|
self._installed_lock = FileLock(os.path.join(self.path, 'installed.json') + '.lock', thread_local=False)
|
|
|
|
def unlock_installed(self):
|
|
self._installed_lock.release(force=True)
|