Skip to content

Commit

Permalink
Further loop changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Dec 24, 2024
1 parent 2aeb48b commit 434dade
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -4813,46 +4813,6 @@ def run_search_loop(self) -> NoReturn:
# self.run_request_search()
self.logger.trace("Starting general search loop: %s", str(not searched))
try:
if not searched:
self.logger.trace("Getting general files")
for (
entry,
todays,
limit_bypass,
series_search,
commands,
) in self.db_get_files():
if totcommands == -1:
totcommands = commands
self.logger.info("Starting search for %s items", totcommands)
if SEARCH_LOOP_DELAY == -1:
loop_delay = 30
else:
loop_delay = SEARCH_LOOP_DELAY
while not self.maybe_do_search(
entry,
todays=todays,
bypass_limit=limit_bypass,
series_search=series_search,
commands=totcommands,
):
self.logger.debug("Waiting for active search commands")
time.sleep(loop_delay)
totcommands -= 1
self.logger.info("Delaying search loop by %s seconds", loop_delay)
time.sleep(loop_delay)
if totcommands == 0:
self.logger.info("All searches completed")
searched = True
elif datetime.now() >= (timer + loop_timer):
self.logger.info(
"Searches not completed, %s remaining", totcommands
)
self.logger.debug(
"%s api calls in %s seconds",
self.api_call_count,
(datetime.now() - self.api_call_timer).seconds,
)
if self.search_by_year:
if years.index(self.search_current_year) != years_count - 1:
years_index += 1
Expand All @@ -4866,6 +4826,46 @@ def run_search_loop(self) -> NoReturn:
self.refresh_download_queue()
self.logger.trace("Restarting loop testing 2")
raise RestartLoopException
self.logger.trace("Getting general files")
for (
entry,
todays,
limit_bypass,
series_search,
commands,
) in self.db_get_files():
if totcommands == -1:
totcommands = commands
self.logger.info("Starting search for %s items", totcommands)
if SEARCH_LOOP_DELAY == -1:
loop_delay = 30
else:
loop_delay = SEARCH_LOOP_DELAY
while not self.maybe_do_search(
entry,
todays=todays,
bypass_limit=limit_bypass,
series_search=series_search,
commands=totcommands,
):
self.logger.debug("Waiting for active search commands")
time.sleep(loop_delay)
totcommands -= 1
self.logger.info("Delaying search loop by %s seconds", loop_delay)
time.sleep(loop_delay)
if totcommands == 0:
self.logger.info("All searches completed")
searched = True
elif datetime.now() >= (timer + loop_timer):
timer = datetime.now()
self.logger.info(
"Searches not completed, %s remaining", totcommands
)
self.logger.debug(
"%s api calls in %s seconds",
self.api_call_count,
(datetime.now() - self.api_call_timer).seconds,
)
except RestartLoopException:
searched = True
self.loop_completed = True
Expand Down

0 comments on commit 434dade

Please sign in to comment.