Skip to content

Timeout

Wait for a simulated time to pass.

Timeout

Bases: Event

Timeout event for sleeping.

Source code in src/asimpy/timeout.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Timeout(Event):
    """Timeout event for sleeping."""

    def __init__(self, env: "Environment", delay: float | int):
        """
        Construct timeout.

        Args:
            env: simulation environment.
            delay: how long to wait.
        """
        assert delay >= 0
        super().__init__(env)
        env.schedule(env.now + delay, self._fire)

    def _fire(self):
        """Handle cancellation case."""
        if self._cancelled:
            return NO_TIME
        self.succeed()

__init__(env, delay)

Construct timeout.

Parameters:

Name Type Description Default
env Environment

simulation environment.

required
delay float | int

how long to wait.

required
Source code in src/asimpy/timeout.py
13
14
15
16
17
18
19
20
21
22
23
def __init__(self, env: "Environment", delay: float | int):
    """
    Construct timeout.

    Args:
        env: simulation environment.
        delay: how long to wait.
    """
    assert delay >= 0
    super().__init__(env)
    env.schedule(env.now + delay, self._fire)