Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of non-dict configs #583

Merged
merged 1 commit into from
Jul 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions scenario_player/tasks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ def __call__(self, *args, **kwargs):
self._runner.running_task_count += 1
self._start_time = time.monotonic()
try:
timeout_s = None
# Config can be something else than a dictionary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would the config be something else? this seems a problem that should be handled in the caller site, and not here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example in the WaitTask, the config is just an int

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is that it should be fixed there then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we want to support this:

 - wait: 30

instead of

- wait: {time: 30}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propopose to fix that later: #584

if isinstance(self._config, dict):
timeout_s = self._config.get("timeout", self.DEFAULT_TIMEOUT)
# Zero means no timeout is desired
timeout_s = self._config.get("timeout", self.DEFAULT_TIMEOUT)
if timeout_s > 0:
if timeout_s and timeout_s > 0:
log.debug("Running task with timeout", timeout=timeout_s)
exception: Optional[Exception] = None
try:
Expand Down