Skip to content

Invalid execution window when in Schedule when start > end #3321

@souro26

Description

@souro26

When creating a Schedule with start > end, the EventGenerator still executes once at the start time and then deactivates, which results in an invalid configuration of the execution window.

Example:

Schedule(interval=1.0, start=10, end=5)

This configuration logically defines an empty execution window, but the current behavior allows the event to execute at t=10 and then stop, which doesn’t make sense in this context.

Expected Behavior:
A ValueError should be raised during the creation of the Schedule in __post_init__ if start > end, as this represents an invalid time window.

Proposed Fix:
Validate the start and end parameters during initialization in the Schedule class:

if self.start is not None and self.end is not None:
    if self.start > self.end:
        raise ValueError(f"Schedule start ({self.start}) cannot be after end ({self.end})")

This change would enforce the expected behavior and prevent scheduling events with logically invalid times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions