Skip to content

Commit

Permalink
Allow delays smaller than 50ms by setting delaybeforesend to None
Browse files Browse the repository at this point in the history
Pexpect added[1] a default delay of 50ms before send, by default, to work
around an issue with passwords being echod.  This makes it impossible to have
delays smaller than this 50ms, currently.  This commit allows setting
delaybeforesend to None, which is recommended by Pexpect to remove this
additional delay hardcoded in Pexpect's code.

[1] - https://github.com/pexpect/pexpect/blob/master/pexpect/pty_spawn.py#L136-L150
  • Loading branch information
punchagan authored and PierreMarchand20 committed Dec 22, 2023
1 parent 73fad35 commit a1a8332
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Run regression tests
run: |
set enable-bracketed-paste off
python3 -m pytest
python3 -m pytest -v
- name: Check module imports with isort
run: |
Expand Down
3 changes: 3 additions & 0 deletions asciinema_automation/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(
delay,
standard_deviation,
timeout,
delaybeforesend=50 / 1000.0,
):
# Set members from arguments
self.inputfile = inputfile
Expand All @@ -59,6 +60,7 @@ def __init__(
self.delay = delay / 1000.0
self.wait = wait / 1000.0
self.standard_deviation = standard_deviation / 1000.0
self.delaybeforesend = delaybeforesend

# Default values for data members
self.expected = "\n"
Expand Down Expand Up @@ -147,6 +149,7 @@ def execute(self):
)
logger.info(spawn_command)
self.process = pexpect.spawn(spawn_command, logfile=None)
self.process.delaybeforesend = self.delaybeforesend

self.process.expect("\n")
logger.debug(self.process.before)
Expand Down

0 comments on commit a1a8332

Please sign in to comment.