Skip to content

Commit

Permalink
Deduplicate DURATION constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Ketok4321 committed Jan 25, 2024
1 parent 845992d commit 3cb933b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/backends/librespeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

DOWNLOAD_SIZE = 100

DURATION = 15
DL_STREAMS = 6
UP_STREAMS = 3

Expand Down Expand Up @@ -52,11 +51,11 @@ async def check_server(server, results):

return results

async def start(self, server, res, notify):
async def start(self, server, res, notify, duration):
async def perform_test(test, streams, res):
tasks = []

timeout = asyncio.create_task(asyncio.sleep(DURATION))
timeout = asyncio.create_task(asyncio.sleep(duration))

for _ in range(streams):
tasks.append(asyncio.create_task(test(server, res)))
Expand Down
4 changes: 2 additions & 2 deletions src/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from gi.repository import GLib

DURATION = 15 #TODO: This constant is in two places now
DURATION = 15
OVERHEAD_COMPENSATION = 1.06

@dataclass
Expand Down Expand Up @@ -88,7 +88,7 @@ def on_event(type):

GLib.idle_add(self.app.win.test_view.progress.set_visible, True)
self.results = TestResults()
await self.app.backend.start(self.server, self.results, lambda type: GLib.idle_add(on_event, type))
await self.app.backend.start(self.server, self.results, lambda type: GLib.idle_add(on_event, type), DURATION)
GLib.idle_add(self.app.win.test_view.progress.set_visible, False)
except Exception as e:
print(e)
Expand Down

0 comments on commit 3cb933b

Please sign in to comment.