Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(WindowsKeyPoller): change implementation of captured_chars #2701

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading