Skip to content

Conversation

@lordwelch
Copy link
Member

No description provided.

@lordwelch lordwelch force-pushed the on_ratelimit branch 2 times, most recently from 43f5801 to b1c164a Compare December 23, 2024 04:27
@mizaki
Copy link
Contributor

mizaki commented Dec 24, 2024

Did you want to do something like this with taggerwindow->on_ratelimit or do the darkmode check once at start?

palette: QtGui.QPalette = self.palette()
window_color = palette.color(QtGui.QPalette.ColorRole.Window)
is_darkmode = True if window_color.lightness() < 100 else False
if is_darkmode:
    toast.applyPreset(ToastPreset.WARNING_DARK)
else:
    toast.applyPreset(ToastPreset.WARNING)

@mizaki
Copy link
Contributor

mizaki commented Dec 30, 2024

Using the autotag window, if you cancel when the limit is waiting, the cancel (showing other windows) doesn't trigger until the wait time is over, even if the GUI wait window is closed.

@lordwelch
Copy link
Member Author

I don't know of a way to fix that in python. In Go that's easy comic-hasher/cv/cv.go but I don't know how to notify a sleeping thread in python.

@mizaki
Copy link
Contributor

mizaki commented Jan 5, 2025

I don't know of a way to fix that in python. In Go that's easy comic-hasher/cv/cv.go but I don't know how to notify a sleeping thread in python.

It shouldn't be too much of an issue as the wait should only be a few seconds most of the time? I upped it to 60 seconds wait time for testing.

@lordwelch
Copy link
Member Author

It gets kind of long when you hit the 200/hour limit

@mizaki
Copy link
Contributor

mizaki commented Jan 6, 2025

This might be another "not easy" but is there anyway to update the limiter if there is a time sent back by the server, i.e (x-ratelimit-retry-after?

@lordwelch
Copy link
Member Author

No, you'd have to basically do a whole rewrite
But that's easy to do outside of this rate-limiting it tells you how long you need to wait

@mizaki
Copy link
Contributor

mizaki commented Jan 9, 2025

Triggering the limiter with the issue window causes:

2025-01-09T00:54:23 | comictagger | CRITICAL | Uncaught exception: AttributeError: 'IssueSelectionWindow' object has no attribute 'iddialog'
Traceback (most recent call last):
  File "/home/workspace/comictagger/comictaggerlib/seriesselectionwindow.py", line 270, in cell_double_clicked
    self.show_issues()
  File "/home/workspace/comictagger/comictaggerlib/seriesselectionwindow.py", line 452, in show_issues
    selector = IssueSelectionWindow(self, self.config, self.talker, self.series_id, self.issue_number)
  File "/home/workspace/comictagger/comictaggerlib/issueselectionwindow.py", line 63, in __init__
    self.perform_query()
  File "/home/workspace/comictagger/comictaggerlib/issueselectionwindow.py", line 84, in perform_query
    for x in self.talker.fetch_issues_in_series(
  File "/home/workspace/comictagger/comictalker/talkers/comicvine.py", line 420, in fetch_issues_in_series
    for x in self._fetch_issues_in_series(
  File "/home/workspace/comictagger/comictalker/talkers/comicvine.py", line 848, in _fetch_issues_in_series
    cv_response: CVResult[list[CVIssue]] = self._get_cv_content(
  File "/home/workspace/comictagger/comictalker/talkers/comicvine.py", line 719, in _get_cv_content
    with self.limiter.ratelimit(
  File "/home/workspace/comictagger/comictalker/vendor/pyrate_limiter/limit_context_decorator.py", line 70, in __enter__
    self.delayed_acquire()
  File "/home/workspace/comictagger/comictalker/vendor/pyrate_limiter/limit_context_decorator.py", line 95, in delayed_acquire
    self.on_rate_limit.callback(full_delay_time, delay_time)
  File "/home/workspace/comictagger/comictaggerlib/seriesselectionwindow.py", line 273, in on_ratelimit
    self.log_output(
  File "/home/workspace/comictagger/comictaggerlib/seriesselectionwindow.py", line 392, in log_output
    if self.iddialog is not None:
AttributeError: 'IssueSelectionWindow' object has no attribute 'iddialog'

The class IssueSelectionWindow(SeriesSelectionWindow): inits with super().__init__(parent, config, talker) and so doesn't create the self.iddialog because the series_name (L:206) is empty.

@lordwelch
Copy link
Member Author

That should be better!

@mizaki
Copy link
Contributor

mizaki commented Jan 15, 2025

Getting the issue window stuck (using 3 requests a minute) and no toast. Then after it's finished, two toasts.
Initial error: QObject::startTimer: Timers cannot be started from another thread

Video:

Screencast_20250115_215716.mp4

@lordwelch
Copy link
Member Author

Not sure what timer is causing that... It works much better on macos, I'll have to test some stuff on linux

@mizaki
Copy link
Contributor

mizaki commented Jan 16, 2025

With the Series Window when the limiter triggers it doesn't give the QObject::startTimer: Timers cannot be started from another thread error. It locks the GUI and then the toast appears after the timer is over the same as the issue window.

Because it's in a thread, it's going to be a pain to debug?

@lordwelch
Copy link
Member Author

I probably have to do some bullshit with a new qobject and moveToThread

@lordwelch
Copy link
Member Author

@mizaki try this and see if it still hangs

@mizaki
Copy link
Contributor

mizaki commented Jan 23, 2025

That seems to have sorted the fetch issue list.

Triggering the limit by clicking each issue after still has the problem but I guess you'd expect that going by the fix.

@mizaki
Copy link
Contributor

mizaki commented Jul 24, 2025

Using the autotag window, if you cancel when the limit is waiting, the cancel (showing other windows) doesn't trigger until the wait time is over, even if the GUI wait window is closed.

As a (not nice) workaround, make the autotag window non-closable when the toast is active and make the toast non-closable? If it's not modal, user should still be able to click cancel in the autotag window?

@lordwelch
Copy link
Member Author

There's actually options for canceling timers/sleep https://docs.python.org/3/library/threading.html#event-objects

I need to finish cleaning up the threads/signals/slots though

@mizaki
Copy link
Contributor

mizaki commented Sep 21, 2025

Trying the latest changes and getting an error when using the test in GUI talker settings:

Original exception was:
Traceback (most recent call last):
  File "/home/bob/workspace/comictagger/comictaggerlib/ui/talkeruigenerator.py", line 80, in call_check_api
    return qtutils.information(TalkerTab.tab, "API Test Success", check_text)
  File "/home/bob/workspace/comictagger/comictaggerlib/ui/qtutils.py", line 255, in information
    qmsg = QtWidgets.QMessageBox(parent)
TypeError: arguments did not match any overloaded call:
  QMessageBox(parent: Optional[QWidget] = None): argument 1 has unexpected type '_collections._tuplegetter'
  QMessageBox(icon: QMessageBox.Icon, title: Optional[str], text: Optional[str], buttons: QMessageBox.StandardButton = QMessageBox.NoButton, parent: Optional[QWidget] = None, flags: Qt.WindowType = Qt.Dialog|Qt.MSWindowsFixedSizeDialogHint): argument 1 has unexpected type '_collections._tuplegetter'

@mizaki
Copy link
Contributor

mizaki commented Sep 21, 2025

Is it possible to limit the toast to the CT window? Otherwise, if you're in another window it will pop up over the top.

@lordwelch
Copy link
Member Author

88f11cd doesn't seem to work :-(

@mizaki
Copy link
Contributor

mizaki commented Sep 22, 2025

It seems as if autotag goes through the motions but never actually writes the tags.

Also, when the manual pick window for unsure results came up and I picked and accepted:

Traceback (most recent call last):
  File "/home/bob/workspace/comictagger/comictaggerlib/autotagmatchwindow.py", line 193, in accept
    self.save_match()
  File "/home/bob/workspace/comictagger/comictaggerlib/autotagmatchwindow.py", line 228, in save_match
    md, error = self.parent().read_selected_tags(self._tags, ca)
ValueError: too many values to unpack (expected 2)
Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/bob/workspace/comictagger/comictaggerlib/gui.py", line 68, in exception_hook
    self._exception_caught.emit(f"Oops. An unexpected error occurred:\n{log_msg}", trace_back)
TypeError: UncaughtHook._exception_caught[object] signal has 1 argument(s) but 2 provided

Original exception was:
Traceback (most recent call last):
  File "/home/bob/workspace/comictagger/comictaggerlib/autotagmatchwindow.py", line 193, in accept
    self.save_match()
  File "/home/bob/workspace/comictagger/comictaggerlib/autotagmatchwindow.py", line 228, in save_match
    md, error = self.parent().read_selected_tags(self._tags, ca)
ValueError: too many values to unpack (expected 2)

@lordwelch
Copy link
Member Author

It seems as if autotag goes through the motions but never actually writes the tags.

That's just the filelist not updating

@mizaki
Copy link
Contributor

mizaki commented Sep 29, 2025

It seems the covers aren't showing in the autotag window, neither local more remote.

@mizaki
Copy link
Contributor

mizaki commented Sep 29, 2025

It seems the covers aren't showing in the autotag window, neither local more remote.

I managed to get this error which seems likely cause:

2025-09-29T16:28:09 | comictagger                    | CRITICAL | Uncaught exception: NameError: name 'QtNetwork' is not defined
Traceback (most recent call last):
  File "/home/bob/workspace/comictagger/comictaggerlib/imagefetcher.py", line 123, in finish_request
    length = reply.header(QtNetwork.QNetworkRequest.KnownHeaders.ContentLengthHeader)
NameError: name 'QtNetwork' is not defined
Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/bob/workspace/comictagger/comictaggerlib/gui.py", line 68, in exception_hook
    self._exception_caught.emit(f"Oops. An unexpected error occurred:\n{log_msg}", trace_back)
TypeError: UncaughtHook._exception_caught[object] signal has 1 argument(s) but 2 provided

@mizaki
Copy link
Contributor

mizaki commented Sep 29, 2025

The being able to set the wait time didn't make it in? People are going to see Rate limit reached: 94s until next request. Waiting 60s for ratelimit and wonder why not wait the 94s

@mizaki
Copy link
Contributor

mizaki commented Sep 29, 2025

If you cancel the autotag there is no summary window, is that to get around it popping up only after the limiter has run down?

Fix qt imports
Better cancelation
@lordwelch
Copy link
Member Author

The being able to set the wait time didn't make it in?

Nope, that will have to happen later

People are going to see Rate limit reached: 94s until next request. Waiting 60s for ratelimit and wonder why not wait the 94s

I want it obvious that it's waiting for a ratelimit, when it's a manual search or auto-identify it's every 10s

If you cancel the autotag there is no summary window, is that to get around it popping up only after the limiter has run down?

Fixed

It seems the covers aren't showing in the autotag window, neither local more remote.

Fixed

@lordwelch lordwelch merged commit 93a3f20 into comictagger:develop Oct 2, 2025
14 of 23 checks passed
@lordwelch lordwelch deleted the on_ratelimit branch November 4, 2025 05:38
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

Successfully merging this pull request may close these issues.

2 participants