Question

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 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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top