Skip to content

[py] Validate WebSocket response interval correctly - #17984

Open
cuishuang wants to merge 1 commit into
SeleniumHQ:trunkfrom
cuishuang:fix-python-websocket-interval
Open

cuishuang wants to merge 1 commit into
SeleniumHQ:trunkfrom
cuishuang:fix-python-websocket-interval

Conversation

@cuishuang

@cuishuang cuishuang commented Sep 5, 2026

Copy link
Copy Markdown

🔗 Related Issues

💥 What does this PR do?

Fixes Python WebSocket response interval validation.

The existing validation checks timeout < 0 twice:

if not isinstance(interval, (int, float)) or timeout < 0:

As a result, non-positive intervals can pass validation. An interval of -0.1 later reaches sleep(-0.1), while an interval of 0 prevents _wait_until() from reducing its remaining timeout and can cause an infinite loop.

This changes the validation to reject all non-positive interval values:

if not isinstance(interval, (int, float)) or interval <= 0:

A unit regression test covers negative, zero, and positive interval values without requiring a browser or WebSocket server.

🔧 Implementation Notes

The interval must be strictly positive because _wait_until() subtracts it from the remaining timeout and passes it to sleep().

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s):
    • What was generated:
    • I reviewed all AI output and can explain the change

💡 Additional Considerations

🔄 Types of changes

  • Bug fix (backwards compatible)

Signed-off-by: cuishuang <imcusg@gmail.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@CLAassistant

CLAassistant commented Sep 5, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@selenium-ci selenium-ci added the C-py Python Bindings label Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-py Python Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants