Skip to content

Commit

Permalink
Fixes to EventProgress and kubernetes test:
Browse files Browse the repository at this point in the history
- Update EventProgress.watch to complete imediately when event is set
instead of needing every to elapse
- Fix test_adjust_tuning_never_ready not reraising non-matching
RuntimeError
  • Loading branch information
linkous8 committed Apr 17, 2023
1 parent 74e71d4 commit c17dc6c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 20 additions & 1 deletion servo/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import abc
import asyncio
import contextlib
import datetime
import enum
import inspect
Expand Down Expand Up @@ -587,7 +588,25 @@ async def watch(
else:
every = min(Duration("60s"), self.timeout)

return await super().watch(notify, every)
# return await super().watch(notify, every)
async def async_notifier() -> None:
if asyncio.iscoroutinefunction(notify):
await notify(self)
else:
notify(self)

if not self.started:
self.start()

while True:
if self.finished:
break

with contextlib.suppress(asyncio.TimeoutError):
await asyncio.wait_for(
self._event.wait(), timeout=every.total_seconds()
)
await async_notifier()


class Unit(str, enum.Enum):
Expand Down
2 changes: 2 additions & 0 deletions tests/connectors/kubernetes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,8 @@ async def test_adjust_tuning_never_ready(
in str(e)
):
pytest.xfail("Tuning pod shutdown took over 30 seconds")
else:
raise

# Validate the correct error was raised, re-raise if not for additional debugging context
try:
Expand Down

0 comments on commit c17dc6c

Please sign in to comment.