Skip to content

Commit

Permalink
chore: converted analysis scheduler status update interval to config …
Browse files Browse the repository at this point in the history
…variable

and changed its default value for the tests to 0.2 for a significant teardown speedup
  • Loading branch information
jstucke committed Dec 3, 2024
1 parent 8ff0d86 commit 48fcfd9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class Plugin(BaseModel):
ssdeep_ignore: int

intercom_poll_delay: float
analysis_status_update_interval: float = 4.5

throw_exceptions: bool

Expand Down
1 change: 1 addition & 0 deletions src/config/fact-core-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ firmware-file-storage-directory = "/media/data/fact_fw_data"
block-delay = 0.1
ssdeep-ignore = 1
intercom-poll-delay = 1.0
analysis-status-update-interval = 4.5
scheduling-worker-count = 4
collector-worker-count = 2
throw-exceptions = false
Expand Down
1 change: 1 addition & 0 deletions src/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def backend_config(request, common_config, firmware_file_storage_directory) -> c
'block_delay': 0.1,
'ssdeep_ignore': 1,
'intercom_poll_delay': 0.1,
'analysis_status_update_interval': 0.2,
'throw_exceptions': True, # Always throw exceptions to avoid miraculous timeouts in test cases
'plugin_defaults': {'processes': 1},
'unpacking': {
Expand Down
6 changes: 3 additions & 3 deletions src/scheduler/analysis_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from time import time
from typing import TYPE_CHECKING, Dict, Set

import config
from helperFunctions.process import stop_process
from objects.firmware import Firmware
from storage.redis_status_interface import RedisStatusInterface

if TYPE_CHECKING:
from objects.file import FileObject

UPDATE_INTERVAL = 4.5 # a bit less than the update interval on the system health page, FixMe: -> configuration
RECENTLY_FINISHED_DISPLAY_TIME_IN_SEC = 300


Expand Down Expand Up @@ -116,11 +116,11 @@ def _worker_loop(self):
logging.debug(f'updating status (queue: {self.queue.qsize()})')
self._clear_recently_finished()
self._store_status()
next_update_time = current_time + UPDATE_INTERVAL
next_update_time = current_time + config.backend.analysis_status_update_interval
logging.debug('stopped analysis status worker')

def _update_status(self):
update_type, *args = self.queue.get(timeout=UPDATE_INTERVAL)
update_type, *args = self.queue.get(timeout=config.backend.analysis_status_update_interval)
if update_type == _UpdateType.add_update:
self._add_update(*args)
elif update_type == _UpdateType.add_firmware:
Expand Down

0 comments on commit 48fcfd9

Please sign in to comment.