Skip to content

Commit

Permalink
ensure requests can't collide
Browse files Browse the repository at this point in the history
  • Loading branch information
RHammond2 committed Sep 15, 2023
1 parent e745030 commit a709162
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions wombat/core/service_equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,12 @@ def run_scheduled_in_situ(self) -> Generator[Process, None, None]:
)
)

# Avoid requests for the same system and therefore a timing collision
seconds_to_wait, *_ = (
self.env.random_generator.integers(low=0, high=10, size=1) / 3600.0
)
yield self.env.timeout(seconds_to_wait)

request = self.get_next_request()
if request is None:
if not self.at_port:
Expand Down Expand Up @@ -1739,6 +1745,12 @@ def run_unscheduled_in_situ(self) -> Generator[Process, None, None]:
return

while True and self.env.now < charter_end_env_time:
# Avoid requests for the same system and therefore a timing collision
seconds_to_wait, *_ = (
self.env.random_generator.integers(low=0, high=10, size=1) / 3600.0
)
yield self.env.timeout(seconds_to_wait)

request = self.get_next_request()
if request is None:
yield self.env.process(
Expand Down Expand Up @@ -1823,8 +1835,12 @@ def run_unscheduled_in_situ(self) -> Generator[Process, None, None]:
)
)

# Wait one second to ensure there are no timing collisions
yield self.env.timeout(1.0 / 3600)
# Avoid requests for the same system and therefore a timing collision
seconds_to_wait, *_ = (
self.env.random_generator.integers(low=0, high=10, size=1) / 3600.0
)
yield self.env.timeout(seconds_to_wait)

request = self.get_next_request()
if request is None:
yield self.env.process(
Expand Down

0 comments on commit a709162

Please sign in to comment.