Skip to content

Replace magic number in _FakeDoneEvent with named constant#1530

Merged
caronc merged 2 commits intoxmpp-test-race-condition-fixfrom
copilot/sub-pr-1526-yet-again
Feb 20, 2026
Merged

Replace magic number in _FakeDoneEvent with named constant#1530
caronc merged 2 commits intoxmpp-test-race-condition-fixfrom
copilot/sub-pr-1526-yet-again

Conversation

Copy link

Copilot AI commented Feb 20, 2026

The pre_wait class attribute on _FakeDoneEvent used a bare 0.02 float with no explanation of why that specific duration was chosen, making the intent opaque.

Changes

  • New constant WORKER_THREAD_STARTUP_DELAY: float = 0.02 defined at module level in tests/test_plugin_xmpp.py, with a comment explaining it exists to give the worker thread enough time to reach a known checkpoint before the test forces the timeout branch — without adding unnecessary wall-clock overhead to the test suite.
  • _FakeDoneEvent.pre_wait now references WORKER_THREAD_STARTUP_DELAY instead of the inline literal.
# Before
pre_wait: float = 0.02

# After
# Seconds to sleep before forcing the timeout branch in _FakeDoneEvent.wait().
# This gives the worker thread enough time to progress to a known checkpoint
# (e.g. event loop created, client instantiated) without relying on a longer
# wall-clock timeout that would slow tests down.
WORKER_THREAD_STARTUP_DELAY: float = 0.02

class _FakeDoneEvent:
    pre_wait: float = WORKER_THREAD_STARTUP_DELAY

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ELAY

Co-authored-by: caronc <850374+caronc@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on preventing XMPP racing condition test failures Replace magic number in _FakeDoneEvent with named constant Feb 20, 2026
Copilot AI requested a review from caronc February 20, 2026 21:03
@caronc caronc marked this pull request as ready for review February 20, 2026 21:16
@caronc caronc merged commit 6c09a65 into xmpp-test-race-condition-fix Feb 20, 2026
2 checks passed
@caronc caronc deleted the copilot/sub-pr-1526-yet-again branch February 20, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants