def checking():
     # yield control so that the second put can proceed
     # XXX: @inlineCallbacks seems to resume the generator
     # in the same tick if the result is immediately
     # available (not a deferred, or an already resolved
     # deferred), so we need to force next tick by "sleep".
     # I think this is bad behavior from @inlineCallbacks.
     yield sleep(0)
     self.assertEqual(var["count"], 2, "second (buffered) put succeeds")
     d.callback(CLOSED)
 def taking():
     yield sleep(0.005)
     yield take(ch)
 def closing():
     yield sleep(0.005)
     ch.close()
 def putting():
     yield sleep(0.005)
     yield put(ch, 42)