Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Aug 1, 2023
1 parent b16c11e commit ae9adf8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 0 additions & 1 deletion pioreactor/cli/pios.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def _thread_function(unit: str) -> bool:
return False
except ErrorReturnCode_1 as e:
logger.error(f"Error occurred: {e}. See logs for more.")
logger.debug(e.stderr, exc_info=True)
return False

for unit in units:
Expand Down
19 changes: 11 additions & 8 deletions pioreactor/tests/test_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,22 @@ def sample_function():


def test_repeated_timer_interval_accuracy_with_pause_unpause():
counter = [0]
counter = {"_": 0}

def sample_function():
counter[0] += 1
counter["_"] += 1

interval = 1
rt = RepeatedTimer(interval, sample_function)
interval = 1.0
rt = RepeatedTimer(interval, sample_function, run_after=0.0)
rt.start()
time.sleep(1)
time.sleep(0.05) # offset slightly avoid race conditions

time.sleep(1.0)
assert counter["_"] == 1
rt.pause()
time.sleep(2)
time.sleep(2.0)
rt.unpause()
time.sleep(1)
time.sleep(1.0)
rt.cancel()
# The timer should have run only 2 times since we paused for 2 seconds
assert counter[0] == 2
assert counter["_"] == 2
2 changes: 1 addition & 1 deletion pioreactor/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Append "dev" if a dev version
# Append "rc0" if a rc version
__version__ = "23.7.31"
__version__ = "23.7.31.dev"


def _get_hardware_version() -> tuple[int, int] | tuple[int, int, str]:
Expand Down

0 comments on commit ae9adf8

Please sign in to comment.