SoundAdmin.add_view fix

This commit is contained in:
bkfox
2023-01-25 16:21:19 +01:00
parent 4c3878a300
commit c2cd3b0301
6 changed files with 40 additions and 23 deletions

View File

@ -114,16 +114,16 @@ class MonitorHandler(PatternMatchingEventHandler):
pool = None
jobs = {}
def __init__(self, subdir, pool):
def __init__(self, subdir, pool, **sync_kw):
"""
subdir: AIRCOX_SOUND_ARCHIVES_SUBDIR or AIRCOX_SOUND_EXCERPTS_SUBDIR
:param str subdir: sub-directory in program dirs to monitor \
(AIRCOX_SOUND_ARCHIVES_SUBDIR or AIRCOX_SOUND_EXCERPTS_SUBDIR);
:param concurrent.futures.Executor pool: pool executing jobs on file change;
:param **sync_kw: kwargs passed to `SoundFile.sync`;
"""
self.subdir = subdir
self.pool = pool
if self.subdir == settings.AIRCOX_SOUND_ARCHIVES_SUBDIR:
self.sync_kw = {'type': Sound.TYPE_ARCHIVE}
else:
self.sync_kw = {'type': Sound.TYPE_EXCERPT}
self.sync_kw = sync_kw
patterns = ['*/{}/*{}'.format(self.subdir, ext)
for ext in settings.AIRCOX_SOUND_FILE_EXT]
@ -156,7 +156,6 @@ class MonitorHandler(PatternMatchingEventHandler):
self.jobs[key] = handler
def done(r):
print(':::: job done', key)
if self.jobs.get(key) is handler:
del self.jobs[key]
handler.future.add_done_callback(done)