You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the train traversal method, the with block at line 87 will release the resource from the train once the train has finished traversing the current segment. However, in the next loop iteration, the train may not be immediately transferred to the next segment (due to an enforced arrival time, or having to wait to use the next segment). While it waits, it should still be using the previous component's resource, but in the current implementation it is not, so the previous component's resource could have a higher number of free usage slots than it should.
A simple fix would be to not use the with statement and explicitly calling resource.release() (passing in the previous req object) when the train is successfully transferred to its next segment (in the next iteration of the loop).
So the key here is to make sure that we're not losing anything by getting rid of the with in place of an explicit request/release. Otherwise the suggested fix makes sense.
In the train traversal method, the
with
block at line 87 will release the resource from the train once the train has finished traversing the current segment. However, in the next loop iteration, the train may not be immediately transferred to the next segment (due to an enforced arrival time, or having to wait to use the next segment). While it waits, it should still be using the previous component's resource, but in the current implementation it is not, so the previous component's resource could have a higher number of free usage slots than it should.A simple fix would be to not use the
with
statement and explicitly callingresource.release()
(passing in the previousreq
object) when the train is successfully transferred to its next segment (in the next iteration of the loop).https://github.com/transit-analytics-lab/spur/blob/8b4eb0c45b0b5687077b18cc4024ca9a03a494b2/spur/core/train.py#L69-L121
The text was updated successfully, but these errors were encountered: