Inclusion de un ratelimit usando cache
Necesitaba un ratelimit que estuviera disponible en todos los workers, cosa que aparentemente la libreria que estaba usando no tomaba en cuenta asi que la mejor idea que tuve es aprovechar el cache y usarlo para generar el ratelimit :3 asi que como todos los workers se comunican con el mismo cache, todos van a compartir el mismo lock
This commit is contained in:
@@ -6,8 +6,7 @@ musicbrainz entrega exceptuando los errores.
|
||||
from urllib.parse import quote, urlencode
|
||||
import logging
|
||||
import requests
|
||||
from ratelimit import limits, sleep_and_retry
|
||||
from utils import sanitize_keys
|
||||
from utils import sanitize_keys, ratelimit
|
||||
|
||||
HEADERS = {'accept': 'application/json', 'user-agent': 'MusicList/1.0 (danielcortes.xyz)'}
|
||||
MB_HOST = 'https://musicbrainz.org/ws/2'
|
||||
@@ -37,8 +36,6 @@ def _do_request(url):
|
||||
return response
|
||||
|
||||
|
||||
@sleep_and_retry
|
||||
@limits(calls=1, period=1)
|
||||
def _do_request_mb(url):
|
||||
"""Does a request to a path of musicbrainz and returns the dictionary representing the json
|
||||
response
|
||||
@@ -52,6 +49,7 @@ def _do_request_mb(url):
|
||||
:return: The dictionary with the response or the status and his an error message
|
||||
"""
|
||||
|
||||
ratelimit()
|
||||
response = _do_request(url)
|
||||
|
||||
if response.status_code == 200:
|
||||
|
||||
Reference in New Issue
Block a user