Skip to content

Commit

Permalink
refactor(WindowsKeyPoller): change implementation of captured_chars (…
Browse files Browse the repository at this point in the history
…list -> deque)
  • Loading branch information
tdadela committed May 5, 2024
1 parent eb95466 commit 8ce03c4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions locust/input_events.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import collections
import logging
import os
import sys
Expand Down Expand Up @@ -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:
Expand All @@ -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)

Expand All @@ -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

Expand Down

0 comments on commit 8ce03c4

Please sign in to comment.