A Simpy-Store is filled with elements {0}...{9}
car_Fleet = simpy.Store(env, capacity=10)
i = 0
for i in range(10):
car_Fleet.put({i})
i += 1
When requesting an item from that store
car_id = yield car_Fleet.get()
print(car_id)
the print statement returns the "value" of the Simpy-Store item, for example {4}
But when using a simpy condition event
with car_Fleet.get() as req:
patience = 2
results = yield req | env.timeout(patience)
wait = env.now - arrive
if req in results:
.....
print(req)
.....
else:
# We quit
...
The print(req)
(also print(req.value)
) statement returns "<StoreGet() object at 0x7f8e2681da50>
" and not the value of the requested item as in the code above.
Also print(results)
returns: <ConditionValue {<StoreGet() object at 0x7fe1c37f4b80>: <StoreGet() object at 0x7fe1c37f41f0>}>
How can one access the value instead of the address of the item requested from the store?
Edit: Michaels comment solved the problem. The results
variable can be accessed as follows. By using results[req]
one can retrieve the name of the requested item. When returning an Item to the store it's also important to pass results[req]
with carFleet.put
.