Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MusicBrainz connection network error handling differences between beets version 1.6 and 2+ #5553

Open
jellybuns0x opened this issue Dec 18, 2024 · 0 comments

Comments

@jellybuns0x
Copy link

I've been trying to get to the bottom of a network issue for the last few weeks while importing that has been preventing me from being able to successfully run through a few thousand albums. While I cannot solve the underlying issue to prevent this error from happening, it seems the way beets handles this error has changed since 1.6 NetworkError from musicbrainzng.

In 1.6 the import process hangs for a while, the hung thread eventually fails gracefully, an exception is logged, a new set of threads are spawned and the import process continues. In 2.2 I've noticed when this same exception occurs, the beets process is killed completely. Both installs of beets I'm using to test this are on 1.7.1 of musibrainzng bindings. I've come across this problem in both the latest linuxserver.io docker image and a manual setup on a debian vm. Behavior is also the same regardless of threaded value set yes/no.

Problem

Running this command in verbose (-vv) mode:

$ beet -vv import /downloads

Led to this problem:

Sending event: import_task_created
Traceback (most recent call last):
  File "/usr/lib/python3.11/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.11/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.11/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.11/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.11/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/lib/python3.11/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3.11/http/client.py", line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ssl.py", line 517, in wrap_socket
    return self.sslsocket_class._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ssl.py", line 1108, in _create
    self.do_handshake()
  File "/usr/lib/python3.11/ssl.py", line 1379, in do_handshake
    self._sslobj.do_handshake()
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/app/venv/lib/python3.11/site-packages/musicbrainzngs/musicbrainz.py", line 497, in _safe_read
    f = opener.open(req)
        ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 519, in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 110] Connection timed out>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/app/venv/lib/python3.11/site-packages/beets/autotag/mb.py", line 511, in match_album
    res = musicbrainzngs.search_releases(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/venv/lib/python3.11/site-packages/musicbrainzngs/musicbrainz.py", line 978, in search_releases
    return _do_mb_search('release', query, fields, limit, offset, strict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/venv/lib/python3.11/site-packages/musicbrainzngs/musicbrainz.py", line 782, in _do_mb_search
    return _do_mb_query(entity, '', [], params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/venv/lib/python3.11/site-packages/musicbrainzngs/musicbrainz.py", line 728, in _do_mb_query
    return _mb_request(path, 'GET', auth_required, args=args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/venv/lib/python3.11/site-packages/musicbrainzngs/musicbrainz.py", line 417, in __call__
    return self.fun(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/venv/lib/python3.11/site-packages/musicbrainzngs/musicbrainz.py", line 690, in _mb_request
    resp = _safe_read(opener, req, body)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/venv/lib/python3.11/site-packages/musicbrainzngs/musicbrainz.py", line 525, in _safe_read
    raise NetworkError(cause=exc)
musicbrainzngs.musicbrainz.NetworkError: caused by: <urlopen error [Errno 110] Connection timed out>

Error: MusicBrainz not reachable in release search with query {...

Setup

  • OS: docker on linux and debian 12
  • Python version: 3.11
  • beets version: 1.6 and 2.2
  • Turning off plugins made problem go away (yes/no): no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant