Skip to content

Commit

Permalink
Correcting event holds
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesArruda committed Mar 4, 2025
1 parent 688b07f commit a867165
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/upstage_des/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ def __init__(

self.put_location = put_location
self.put_object = put_object
self._request_event: ContainerPut | StorePut | None = None

def as_event(self) -> ContainerPut | StorePut:
"""Convert event to a ``simpy`` Event.
Expand All @@ -342,7 +343,8 @@ def as_event(self) -> ContainerPut | StorePut:
Put request as a simpy event.
"""
self._request_event = self.put_location.put(self.put_object)
if self._request_event is None:
self._request_event = self.put_location.put(self.put_object)
return self._request_event


Expand Down Expand Up @@ -563,6 +565,7 @@ def __init__(
self.get_args = get_args
self.get_kwargs = get_kwargs
self.__is_store = issubclass(get_location.__class__, SIM.Store)
self._request_event: ContainerGet | StoreGet | None = None

def calculate_time_to_complete(self) -> float:
"""Calculate time elapsed until the event is triggered.
Expand All @@ -580,10 +583,11 @@ def as_event(self) -> ContainerGet | StoreGet:
ContainerGet | StoreGet
"""
# TODO: optional checking for container types for feasibility
self._request_event = self.get_location.get(
*self.get_args,
**self.get_kwargs,
)
if self._request_event is None:
self._request_event = self.get_location.get(
*self.get_args,
**self.get_kwargs,
)
return self._request_event

def get_value(self) -> tyAny:
Expand Down

0 comments on commit a867165

Please sign in to comment.