Esempio n. 1
0
 def do_write(self):
     """See :meth:`versile.reactor.io.IVByteHandleOutput.do_write`\ ."""
     try:
         if self._sock_out_closed:
             self.stop_writing()
         elif not self._sock_enabled:
             self.stop_reading()
         elif not self._sock_connected:
             # Write event indicates socket is now connected
             if not self._sock_peer:
                 try:
                     self._sock_peer = VSocketPeer.from_sock(self.sock)
                 except IOError as e:
                     # ISSUE - current handling of this exc causes
                     # reactor to loop until getpeername resolves
                     self.log.debug('getpeername failed errno %s' % e.errno)
                     return
             self._set_sock_connected()
         elif not self._sock_active:
             if self._sock_do_activation_write():
                 if self._sock_conclude_activation():
                     self._set_sock_active()
                     self._sock_activated()
                 else:
                     self.close_io(VFIOLost())
         else:
             self.active_do_write()
     except VIOCompleted as e:
         self.close_input(VFIOCompleted(e))
     except VIOLost as e:
         self.close_input(VFIOLost(e))
Esempio n. 2
0
 def _p_abort(self):
     if not self._pi_aborted:
         self._pi_aborted = True
         self._pi_produced = self._pi_prod_lim = 0
         self._reader.close_input(VFIOCompleted())
         if self._pi_consumer:
             self._pi_consumer.abort()
             self._p_detach()
Esempio n. 3
0
 def _p_abort(self, force=False):
     if not self._pi_aborted or force:
         self._pi_aborted = True
         self._pi_produced = self._pi_prod_lim = 0
         if not self._sock_in_closed:
             self.close_input(VFIOCompleted())
         if self._pi_consumer:
             self._pi_consumer.abort()
             self._p_detach()
Esempio n. 4
0
 def _c_abort(self):
     if not self._ci_aborted:
         self._ci_aborted = True
         self._ci_eod = True
         self._ci_consumed = self._ci_lim_sent = 0
         self._wbuf.clear()
         self._writer.close_output(VFIOCompleted())
         if self._ci_producer:
             self._ci_producer.abort()
             self._c_detach()
Esempio n. 5
0
 def _c_abort(self, force=False):
     if not self._ci_aborted or force:
         self._ci_aborted = True
         self._ci_eod = True
         self._ci_consumed = self._ci_lim_sent = 0
         self._wbuf.clear()
         if not self._sock_out_closed:
             self.close_output(VFIOCompleted())
         if self._ci_producer:
             self._ci_producer.abort()
             self._c_detach()
Esempio n. 6
0
    def _c_end_consume(self, clean):
        if self._ci_eod:
            return
        self._ci_eod = True
        self._ci_eod_clean = clean

        if not self._wbuf:
            self.close_output(VFIOCompleted())
            if self._ci_producer:
                self._ci_producer.abort()
                self._c_detach()
Esempio n. 7
0
 def do_read(self):
     """See :meth:`versile.reactor.io.IVByteHandleInput.do_read`\ ."""
     try:
         if self._sock_in_closed:
             self.stop_reading()
         elif not self._sock_enabled:
             self.stop_reading()
         elif not self._sock_connected:
             self.stop_reading()
         elif not self._sock_active:
             if self._sock_do_activation_read():
                 if self._sock_conclude_activation():
                     self._set_sock_active()
                     self._sock_activated()
                 else:
                     self.close_io(VFIOLost())
         else:
             self.active_do_read()
     except VIOCompleted as e:
         self.close_input(VFIOCompleted(e))
     except VIOLost as e:
         self.close_input(VFIOLost(e))