Release resource being held by another process
In SimPy, if I've process a
, b
and resource r
and do:
yield request, self, r #request done in process a
How can I release the resource from开发者_如何学Python process b?
yield release, a, r #release done in b (being a an instance of class a), doesn't work
I've also tried:
r.activeQ.remove(a)
And it actually removes from the active queue, however it won't do all the implicit steps made when doing a yield
and it turns out to be kind of pointless.
Can it be done? if yes, how?
Well, my problem was process b
was actually inactive and therefore any yield
call would be unsuccessful.
A workaround I came up with was
activate(a, a.function()) #called from process b
Where
class a(Process):
def function(self):
yield release, self, r
yield passivate, self
Hope this can help anyone out there having the same problem.
精彩评论