I modified Gordon's close handler to not futz with the response queue and instead call ch.close(msg). I also modified the channel to store the closing message and check before any operation that the channel is closed and if not raise a new exception with the previously stored message. This should obviate the need for any sort of assertChannelOpen() and assertChannelClean() since those will effectively happen whenever a channel is used.

This also has the benefit of reporting the closing exception for *any* subsequent attempt to use the channel instead of just for the first one to read from the response queue after the channel is closed.

Gordon Sim wrote:
Alan Conway wrote:
Yup I knew the cleanup stuff was a bit dodgy. How does this sound:

TestBase: add these functions:

assertChannelOpen(chan): fail if chan is closed or has an exception.
assertChannelClean(chan): fail if channel has exceptions

I'm not sure whether this second one is needed. From a protocol perspective, a channel exception *is* a channel.close i.e. if there is an exception then it closed the channel.

It would be useful to have a means of checking this on the Channel class itself, which may be exactly what you are proposing, with any assertion utility method using that facility.

openChannel(id): return channel, add it to self.channelsUsed

This is to allow the channels to be tracked? Do we need this or could we not just check the list of known channels for the client?

In unit tests:
 1. Call openChannel rather than using client directly.
 2. After nowait ops call assertChannelOpen (*)

In tearDown:
 1. for ch in self.channelsUsed: close, note any exceptions
 2. Open new channel to clean up qs and exs. note any exceptions
 3. Close that channel
 4. If any exceptions noted above, fail the test.

I'll implement that today unless anyone has better ideas.

Cheers,
Alan.

Reply via email to