Skip to content

Commit

Permalink
Merge pull request #3003 from bemeurer/master
Browse files Browse the repository at this point in the history
Parallelize absubmit
  • Loading branch information
sampsyo committed Aug 14, 2018
2 parents 86d3537 + 4eafa40 commit 4242a6b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
20 changes: 16 additions & 4 deletions beetsplug/absubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import os
import subprocess
import tempfile
import sys

from multiprocessing.pool import ThreadPool
from distutils.spawn import find_executable
import requests

Expand Down Expand Up @@ -104,10 +106,20 @@ def commands(self):
def command(self, lib, opts, args):
# Get items from arguments
items = lib.items(ui.decargs(args))
for item in items:
analysis = self._get_analysis(item)
if analysis:
self._submit_data(item, analysis)
if sys.version_info[0] < 3:
for item in items:
self.analyze_submit(item)
else:
# Create threadpool
pool = ThreadPool()
pool.map(self.analyze_submit, items)
pool.close()
pool.join()

def analyze_submit(self, item):
analysis = self._get_analysis(item)
if analysis:
self._submit_data(item, analysis)

def _get_analysis(self, item):
mbid = item['mb_trackid']
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ New features:
:user:`shuaiscott`
* New options for Google Play Music authentication in gmusic plugin.
:user:`thetarkus`
* The `absubmit` plugin now works in parallel.
Thanks to :user:`bemeurer`
:bug:`2442`

Fixes:

Expand Down

0 comments on commit 4242a6b

Please sign in to comment.