Skip to content

Commit

Permalink
Open/close pool at begin/end of import session
Browse files Browse the repository at this point in the history
  • Loading branch information
ybnd committed Jan 30, 2020
1 parent 388d2d2 commit 79c5535
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions beetsplug/replaygain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,8 @@ def __init__(self):

# On-import analysis.
if self.config['auto']:
self.register_listener('import_begin', self.import_begin)
self.register_listener('import', self.import_end)
self.import_stages = [self.imported]

# Formats to use R128.
Expand Down Expand Up @@ -1442,6 +1444,16 @@ def close_pool(self):
self.pool.close()
self.pool.join()

def import_begin(self, session):
"""Handle `import_begin` event -> open pool
"""
self.open_pool(self.config['threads'].get(int))

def import_end(self, paths):
"""Handle `import` event -> close pool
"""
self.close_pool()

def imported(self, session, task):
"""Add replay gain info to items or albums of ``task``.
"""
Expand Down

0 comments on commit 79c5535

Please sign in to comment.