resources.VidigiStore
resources.VidigiStore(self, env, num_resources=None, capacity=float('inf'))A wrapper around SimPy’s Store that allows using a context manager pattern similar to resource requests.
This allows code like:
with store.request() as req: yield req # Use the item that was obtained yield env.timeout(10) # Item is automatically returned when exiting the context
AI USE DISCLOSURE: This code was generated by Claude 3.7 Sonnet. It has been evaluated and tested by a human.
Attributes
| Name | Description |
|---|---|
| capacity | Get the capacity of the store |
| items | Get all items currently in the store |
Methods
| Name | Description |
|---|---|
| cancel_get | Cancels a pending get request by removing it from the queue. |
| get | Alias for request() to maintain compatibility with both patterns. |
| get_direct | Get an item from the store without the context manager. |
| populate | Populate this VidigiStore with VidigiResource objects. |
| put | Put an item into the store. |
| request | Request context manager for getting an item from the store. |
| request_direct | Alias for get_direct() to maintain consistent API with SimPy resources. |
cancel_get
resources.VidigiStore.cancel_get(get_event)Cancels a pending get request by removing it from the queue.
get
resources.VidigiStore.get()Alias for request() to maintain compatibility with both patterns.
Returns: A context manager for getting an item
get_direct
resources.VidigiStore.get_direct()Get an item from the store without the context manager. Use this if you don’t want to automatically return the item.
Returns: A get event that can be yielded
populate
resources.VidigiStore.populate(num_resources)Populate this VidigiStore with VidigiResource objects.
Creates num_resources VidigiResource objects and adds them to this store.
Each VidigiResource is initialized with a capacity of 1 and a unique ID starting at 1.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| num_resources | int | The number of VidigiResource objects to create and add to the store. | required |
Returns
| Name | Type | Description |
|---|---|---|
| None |
put
resources.VidigiStore.put(item)Put an item into the store.
Args: item: The item to put in the store
request
resources.VidigiStore.request()Request context manager for getting an item from the store. The item is automatically returned when exiting the context.
Usage: with store.request() as req: yield req # This yields the get event # Now we have the item from the store yield env.timeout(10) # Item is automatically returned when exiting the context
Returns: A context manager that returns the get event and handles returning the item
request_direct
resources.VidigiStore.request_direct()Alias for get_direct() to maintain consistent API with SimPy resources.
Returns: A get event that can be yielded