I don't think it's a good idea to put something specific to the monitor in this fairly generic piece of code. @dwf, do you have any suggestion for getting information back out of a context manager? Maybe it should have a generic callbacks field or something and you could put a method of the monitor in there.