Linux - Ankihub giving popups with errors

When I login to ankihub I get constant popups with the following error even when I am signed out.

Maybe its a python issue?

Debug info:
Anki 2.1.56 (07fd88dd) Python 3.10.9 Qt 6.4.2 PyQt 6.4.0
Platform: Linux-6.1.7-arch1-1-x86_64-with-glibc2.36
Flags: frz=False ao=True sv=2
Add-ons, last update check: 2023-01-25 03:00:45
Add-ons possibly involved: ⁨AnkiHub⁩

— Logging error —
Traceback (most recent call last):
File “/usr/lib/python3.10/logging/init.py”, line 1103, in emit
stream.write(msg + self.terminator)
BlockingIOError: [Errno 11] write could not complete without blocking
Call stack:
File “/usr/lib/python3.10/threading.py”, line 973, in _bootstrap
self._bootstrap_inner()
File “/usr/lib/python3.10/threading.py”, line 1016, in _bootstrap_inner
self.run()
File “/usr/lib/python3.10/threading.py”, line 953, in run
self._target(*self._args, **self._kwargs)
File “/usr/lib/python3.10/concurrent/futures/thread.py”, line 83, in _worker
work_item.run()
File “/usr/lib/python3.10/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 143, in sync_with_ankihub_after_delay
sync.sync_all_decks()
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 29, in sync_all_decks
should_continue = self._sync_deck(ah_did)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 52, in _sync_deck
for chunk in client.get_deck_updates(
File “/home/andrew/.local/share/Anki2/addons21/1322529746/ankihub_client.py”, line 409, in get_deck_updates
response = self._send_request(
File “/home/andrew/.local/share/Anki2/addons21/1322529746/ankihub_client.py”, line 250, in _send_request
response = self.session.send(request)
File “/usr/lib/python3.10/site-packages/requests/sessions.py”, line 708, in send
r = dispatch_hook(“response”, hooks, r, **kwargs)
File “/usr/lib/python3.10/site-packages/requests/hooks.py”, line 30, in dispatch_hook
_hook_data = hook(hook_data, **kwargs)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/addon_ankihub_client.py”, line 27, in logging_hook
LOGGER.debug(f"response content: {pformat(response.json())}")

@agapp11 , There may be something configured in your Linux environment that is causing this. Perhaps the underlying stdout has been set to non-blocking.

are you a programmer or comfortable making small code changes to the addon?

Hello, thank you for your reply.

Im not a programmer but I am comfortable enough making code adjustments if I get some guidance on what to do.

I am not sure if its related to how I setup my linux environment as I have no problems syncing anki itself.

My suspicion is that its related to python version/qt version (have had issues with anki and qt6) but I may be entirely wrong.

But please let me know what to do!

so what should i do regarding the error code i receieve?

In the add-on folder there is a settings.py file with the following:

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        "verbose": {
            "format": "%(levelname)s %(asctime)s %(module)s "
            "%(process)d %(thread)d %(message)s"
        }
    },
    "handlers": {
        "console": {
            "()": stdout_handler,
            "level": "DEBUG",
            "formatter": "verbose",
        },
        "file": {
            "()": file_handler,
            "level": "DEBUG",
            "formatter": "verbose",
        },
    },
    "root": {
        "level": "DEBUG",
        "handlers": ["console", "file"],
    },
}

Try commenting out lines 339-354 like so:

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        "verbose": {
            "format": "%(levelname)s %(asctime)s %(module)s "
            "%(process)d %(thread)d %(message)s"
        }
    },
    # "handlers": {
    #     "console": {
    #         "()": stdout_handler,
    #         "level": "DEBUG",
    #         "formatter": "verbose",
    #     },
    #     "file": {
    #         "()": file_handler,
    #         "level": "DEBUG",
    #         "formatter": "verbose",
    #     },
    # },
    # "root": {
    #     "level": "DEBUG",
    #     "handlers": ["console", "file"],
    # },
}
1 Like

Great! It worked. I updated ankihub and i still got the error. Commenting out lines 339-354 seems to work. Thanks!

1 Like

So after completing the solution suggested previously I am now getting two errors:

I am a paying customer btw

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you’ve discovered the add-on that is causing the problem, please report the issue to the add-on author.
Debug info:
Anki 2.1.56 (07fd88dd) Python 3.10.9 Qt 6.4.2 PyQt 6.4.1
Platform: Linux-6.1.8-arch1-1-x86_64-with-glibc2.36
Flags: frz=False ao=True sv=2
Add-ons, last update check: 2023-01-30 17:53:35
Add-ons possibly involved: ⁨AnkiHub⁩

— Logging error —
Traceback (most recent call last):
File “/usr/lib/python3.10/logging/init.py”, line 1103, in emit
stream.write(msg + self.terminator)
BlockingIOError: [Errno 11] write could not complete without blocking
Call stack:
File “/usr/lib/python3.10/threading.py”, line 973, in _bootstrap
self._bootstrap_inner()
File “/usr/lib/python3.10/threading.py”, line 1016, in _bootstrap_inner
self.run()
File “/usr/lib/python3.10/threading.py”, line 953, in run
self._target(*self._args, **self._kwargs)
File “/usr/lib/python3.10/concurrent/futures/thread.py”, line 83, in _worker
work_item.run()
File “/usr/lib/python3.10/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 183, in sync_with_ankihub_after_delay
sync.sync_all_decks()
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 32, in sync_all_decks
should_continue = self._sync_deck(ah_did)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 44, in _sync_deck
success = self._download_note_updates(ankihub_did)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 59, in _download_note_updates
for chunk in client.get_deck_updates(
File “/home/andrew/.local/share/Anki2/addons21/1322529746/ankihub_client.py”, line 411, in get_deck_updates
response = self._send_request(
File “/home/andrew/.local/share/Anki2/addons21/1322529746/ankihub_client.py”, line 252, in _send_request
response = self.session.send(request)
File “/usr/lib/python3.10/site-packages/requests/sessions.py”, line 708, in send
r = dispatch_hook(“response”, hooks, r, **kwargs)
File “/usr/lib/python3.10/site-packages/requests/hooks.py”, line 30, in dispatch_hook
_hook_data = hook(hook_data, **kwargs)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/addon_ankihub_client.py”, line 27, in logging_hook
LOGGER.debug(f"response content: {pformat(response.json())}“)
Unable to print the message and arguments - possible formatting error.
Use the traceback above to help find the error.
— Logging error —
Traceback (most recent call last):
File “/usr/lib/python3.10/logging/init.py”, line 1104, in emit
self.flush()
File “/usr/lib/python3.10/logging/init.py”, line 1084, in flush
self.stream.flush()
BlockingIOError: [Errno 11] write could not complete without blocking
Call stack:
File “/usr/lib/python3.10/threading.py”, line 973, in _bootstrap
self._bootstrap_inner()
File “/usr/lib/python3.10/threading.py”, line 1016, in _bootstrap_inner
self.run()
File “/usr/lib/python3.10/threading.py”, line 953, in run
self._target(*self._args, **self._kwargs)
File “/usr/lib/python3.10/concurrent/futures/thread.py”, line 83, in _worker
work_item.run()
File “/usr/lib/python3.10/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 183, in sync_with_ankihub_after_delay
sync.sync_all_decks()
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 32, in sync_all_decks
should_continue = self._sync_deck(ah_did)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 44, in _sync_deck
success = self._download_note_updates(ankihub_did)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/sync.py”, line 59, in _download_note_updates
for chunk in client.get_deck_updates(
File “/home/andrew/.local/share/Anki2/addons21/1322529746/ankihub_client.py”, line 411, in get_deck_updates
response = self._send_request(
File “/home/andrew/.local/share/Anki2/addons21/1322529746/ankihub_client.py”, line 252, in _send_request
response = self.session.send(request)
File “/usr/lib/python3.10/site-packages/requests/sessions.py”, line 708, in send
r = dispatch_hook(“response”, hooks, r, **kwargs)
File “/usr/lib/python3.10/site-packages/requests/hooks.py”, line 30, in dispatch_hook
_hook_data = hook(hook_data, **kwargs)
File “/home/andrew/.local/share/Anki2/addons21/1322529746/addon_ankihub_client.py”, line 31, in logging_hook
LOGGER.debug(f"response: {response}”)
Message: ‘response: <Response [200]>’
Arguments: ()

Here is the pastebin to the second error, it was too long to post here.

If the add-on has been updated since you last tried, then the changes you made (commenting out the lines) will have been reverted. I’m guessing that’s what happened. In a future version, we can try to make logging functionality optional so that you can disable it with an add-on config option.

@jakub.f , I wonder if this is happening because the add-on is attempting to log really large log statements (like the entire contents of all of a note’s fields).

Ah that makes sense! I’ve gotten quite a few ankihub updates since the changes where made. Why is the logging function causing the error in the first place? Maybe there is something I can fix (that got broken) so that logging doesn’t need to be disabled?

I do think so. Wrote you on github about how we could reduce the amount of logs and fix the logging errors without needing to disable logs completely.

There may be something you can do, but I’m not sure what. We’ll let you know when we have a fix on our end.

It seems that even after updates to ankihub this issue continues to persist.

In the last couple of hours there was an update to the add-on that should fix this problem (the add-on logs much less by default now). Can you please try again?

Sorry, I didn’t see your message until now. There is no more popups but now when logged into anki hub it makes anki unstable and prone to crashing (or the gui won’t start, but the process will be present and needs to be killed manually from system manager).