mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Limited metadata requests
This commit is contained in:
parent
827b05da8f
commit
48d88b208f
8
maloja/thirdparty/__init__.py
vendored
8
maloja/thirdparty/__init__.py
vendored
@ -11,6 +11,7 @@ import json
|
|||||||
import urllib.parse, urllib.request
|
import urllib.parse, urllib.request
|
||||||
import base64
|
import base64
|
||||||
from doreah.logging import log
|
from doreah.logging import log
|
||||||
|
from threading import Semaphore
|
||||||
|
|
||||||
from ..globalconf import malojaconfig
|
from ..globalconf import malojaconfig
|
||||||
from .. import database
|
from .. import database
|
||||||
@ -22,6 +23,11 @@ services = {
|
|||||||
"metadata":[]
|
"metadata":[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# have a limited number of worker threads so we don't completely hog the cpu with
|
||||||
|
# these requests. they are mostly network bound, so python will happily open up 200 new
|
||||||
|
# requests and then when all the responses come in we suddenly can't load pages anymore
|
||||||
|
thirdpartylock = Semaphore(4)
|
||||||
|
|
||||||
|
|
||||||
def import_scrobbles(identifier):
|
def import_scrobbles(identifier):
|
||||||
for service in services['import']:
|
for service in services['import']:
|
||||||
@ -34,6 +40,7 @@ def proxy_scrobble_all(artists,title,timestamp):
|
|||||||
service.scrobble(artists,title,timestamp)
|
service.scrobble(artists,title,timestamp)
|
||||||
|
|
||||||
def get_image_track_all(track):
|
def get_image_track_all(track):
|
||||||
|
with thirdpartylock:
|
||||||
for service in services["metadata"]:
|
for service in services["metadata"]:
|
||||||
try:
|
try:
|
||||||
res = service.get_image_track(track)
|
res = service.get_image_track(track)
|
||||||
@ -45,6 +52,7 @@ def get_image_track_all(track):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
log("Error getting track image from " + service.name + ": " + repr(e))
|
log("Error getting track image from " + service.name + ": " + repr(e))
|
||||||
def get_image_artist_all(artist):
|
def get_image_artist_all(artist):
|
||||||
|
with thirdpartylock:
|
||||||
for service in services["metadata"]:
|
for service in services["metadata"]:
|
||||||
try:
|
try:
|
||||||
res = service.get_image_artist(artist)
|
res = service.get_image_artist(artist)
|
||||||
|
Loading…
Reference in New Issue
Block a user