Problems with Docker, MusicBrainz and Windows

Maybe we should look at the ratecontrol.py file in the Picard source code?

# ============================================================================
# Throttling/congestion avoidance
# ============================================================================

# Throttles requests to a given hostkey by assigning a minimum delay between
# requests in milliseconds.
#

# Plugins may assign limits to their associated service(s) like so:
#
# >>> from picard.webservice import ratecontrol
# >>> ratecontrol.set_minimum_delay(('myservice.org', 80), 100)  # 10 requests/second


# Minimun delay for the given hostkey (in milliseconds), can be set using
# set_minimum_delay()
REQUEST_DELAY_MINIMUM = defaultdict(lambda: 1000)

# Current delay (adaptive) between requests to a given hostkey.
REQUEST_DELAY = defaultdict(lambda: 1000)  # Conservative initial value.

# Determines delay during exponential backoff phase.
REQUEST_DELAY_EXPONENT = defaultdict(lambda: 0)

# Unacknowledged request counter.
#
# Bump this when handing a request to QNetworkManager and trim when receiving
# a response.
CONGESTION_UNACK = defaultdict(lambda: 0)

# Congestion window size in terms of unacked requests.
#
# We're allowed to send up to `int(this)` many requests at a time.
CONGESTION_WINDOW_SIZE = defaultdict(lambda: 1.0)

# Slow start threshold.
#
# After placing this many unacknowledged requests on the wire, switch from
# slow start to congestion avoidance.  (See `_adjust_throttle`.)  Initialized
# upon encountering a temporary error.
CONGESTION_SSTHRESH = defaultdict(lambda: 0)

# Storage of last request times per host key
LAST_REQUEST_TIMES = defaultdict(lambda: 0)

Maybe the REQUEST_DELAY_MINIMUM variable is hardcoded to 1000 somewhere.

def set_minimum_delay(hostkey, delay_ms):
    """Set the minimun delay between requests
            hostkey is an unique key, for example (host, port)
            delay_ms is the delay in milliseconds
    """
    REQUEST_DELAY_MINIMUM[hostkey] = int(delay_ms)

You still need to host your own server, but you can then set the URL in options to your locally hosted server:

And then you set the rate for that (in a trivial plugin) as follows (as per the example in the ratecontrol.py source code):

PLUGIN_NAME = "Increase request rate for locally-hosted musicbrainz server"
PLUGIN_AUTHOR = "Sophist"
PLUGIN_DESCRIPTION = "Sets the request rate to 1000 per second (1ms delay)."
PLUGIN_VERSION = "1.0"
PLUGIN_API_VERSIONS = ["2.0", "2.1", "2.2"]

from picard.webservice import ratecontrol
ratecontrol.set_minimum_delay(('localhost', 80), 1)  # 1000 requests/second

P.S. I guess it would be nice if Picard could recognise locally hosted sites in some way e.g. if you set the server address to one of the following, then it would assume that it was self-hosted and reduce the minimum delay - however this is not an easy fix:

  • local domain names e.g. localhost, *.local etc.
  • local fixed IP addresses e.g. 10.x.x.x, 192.168.x.x etc.
3 Likes

This plugin has not worked for 6 years.