class ChildSocket(_socketobject): def __init__(self): super(ChildSocket, self).__init__() self.activity_latch = CountDownLatch(1) def _unlatch(self): print "Unlatched" self.activity_latch.countDown() def _wait_on_latch(self): print "Waiting for activity on this child socket" self.activity_latch.await() #self.__class__ = _socketobject print "Latch released" # FIXME raise exception for accept, listen, bind, connect, connect_ex # All ops that allow us to characterize the mode of operation of # this socket as being either Start TLS or SSL when connected def send(self, data): print "Child send", data if self.activity_latch.getCount(): self._post_connect() self._unlatch() return super(ChildSocket, self).send(data) def recv(self, bufsize, flags=0): print "Child recv", bufsize if self.activity_latch.getCount(): self._post_connect() self._unlatch() return super(ChildSocket, self).recv(bufsize, flags) # Presumably we would only close/shutdown immediately under exceptional situations; # regardless release the latch def close(self): if self.activity_latch.getCount(): self._post_connect() self._unlatch() super(ChildSocket, self).close() def shutdown(self, how): if self.activity_latch.getCount(): self._post_connect() self._unlatch() super(ChildSocket, self).shutdown(how)