From 8ce03c451a94d25c1e9e353d2368d8bc40c7dbcb Mon Sep 17 00:00:00 2001 From: tdadela Date: Sun, 5 May 2024 12:44:02 +0200 Subject: [PATCH] refactor(WindowsKeyPoller): change implementation of captured_chars (list -> deque) --- locust/input_events.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/locust/input_events.py b/locust/input_events.py index d34978ff50..273c9c9587 100644 --- a/locust/input_events.py +++ b/locust/input_events.py @@ -1,5 +1,6 @@ from __future__ import annotations +import collections import logging import os import sys @@ -54,7 +55,7 @@ def __init__(self): self.read_handle.SetConsoleMode(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT) self.cur_event_length = 0 self.cur_keys_length = 0 - self.captured_chars = [] + self.captured_chars = collections.deque() except pywintypes.error: raise InitError("Terminal says its a tty but we couldn't enable line input. Keyboard input disabled.") else: @@ -65,7 +66,7 @@ def cleanup(self): def poll(self): if self.captured_chars: - return self.captured_chars.pop(0) + return self.captured_chars.popleft() events_peek = self.read_handle.PeekConsoleInput(10000) @@ -82,7 +83,7 @@ def poll(self): self.cur_event_length = len(events_peek) if self.captured_chars: - return self.captured_chars.pop(0) + return self.captured_chars.popleft() else: return None