Skip to content

pylib spams stack traces on stdout #4665

@davidsauerwein

Description

@davidsauerwein

The anki pylib logs directly to stdout via print(). A lot of the logs don't seem very interesting to user's of the library. They mostly appear to be debug logs. The most noisy that I have observed very frequently (almost 100% of the time) is the following:

blocked main thread for 424ms:
  File "/home/david/coding_stuff/anki/repro.py", line 4, in <module>
    auth = col.sync_login(
  File "/home/david/coding_stuff/anki/.venv/lib/python3.14/site-packages/anki/collection.py", line 1142, in sync_login
    return self._backend.sync_login(
  File "/home/david/coding_stuff/anki/.venv/lib/python3.14/site-packages/anki/_backend_generated.py", line 83, in sync_login
    raw_bytes = self._run_command(1, 3, message.SerializeToString())
  File "/home/david/coding_stuff/anki/.venv/lib/python3.14/site-packages/anki/_backend.py", line 167, in _run_command
    print("".join(traceback.format_stack()))

It can be reproduced with the following snippet

from anki.collection import Collection

col = Collection("collection.anki2")
auth = col.sync_login(
    username=r"<username>",
    password=r"<password>",
    endpoint="https://sync.ankiweb.net/",
)
col.close()

I already have a fix locally. I'll post a PR shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions