Esempio n. 1
0
 def close(self):
     """Close connection and deregister active listeners"""
     AsyncDataStream.close(self)
     self.cleanup_running = True
     for listener in self.bth_throughput_listeners.values():
         listener.close()
     self.bth_throughput_listeners = {}
     self.cleanup_running = False
Esempio n. 2
0
 def __init__(self, btm, *args, **kwargs):
     AsyncDataStream.__init__(self, *args, **kwargs)
     BTControlConnectionBase.__init__(self)
     self.btm = btm
     # sequence ids
     self.snum_btc = 0
     self.snum_bthsets = 0
     self.bth_throughput_listeners = {}
     self.cleanup_running = False
Esempio n. 3
0
  def start_stdio(self):
    fl_in = AsyncDataStream(self.ed, os.fdopen(sys.stdin.fileno(), 'rb', 0, closefd=False))
    fl_out = AsyncDataStream(self.ed, os.fdopen(sys.stdout.fileno(), 'wb', 0, closefd=False), read_r=False)

    sd = ed_shutdown(self.ed)
    fl_in.process_close = sd
    fl_out.process_close = sd

    self.stream = EventStreamServer(fl_in, fl_out)
    self.stream.watch_files = self._watch_files
    self._start_watch()
Esempio n. 4
0
 def request_send(self, event_dispatcher, result_callback, error_callback):
    """Open connection to announce url, open and send request"""
    if not (self.connection is None):
       raise TrackerRequestError("Request {0!a} is still pending.".format(self.connection))
    
    try:
       request_string = self.request_build()
    except urllib.request.URLError:
       self.log(30, 'Error building request for {0!a}:'.format(self.req_url_get()), exc_info=True)
       error_callback(self)
       return
    
    try:
       self.connection = AsyncDataStream.build_sock_connect(event_dispatcher,
          self.address_get(default_port=80))
    except socket.error:
       self.connection = None
       self.result_callback = None
       self.error_callback = None
       error_callback(self)
       return
    
    self.connection.process_input = self.conn_input_handle
    self.connection.process_close = self.conn_close_handle
    self.result_callback = result_callback
    self.error_callback = error_callback
    
    self.connection.send_bytes((request_string,))
Esempio n. 5
0
    def start_stdio(self):
        fl_in = AsyncDataStream(
            self.ed, os.fdopen(sys.stdin.fileno(), 'rb', 0, closefd=False))
        fl_out = AsyncDataStream(self.ed,
                                 os.fdopen(sys.stdout.fileno(),
                                           'wb',
                                           0,
                                           closefd=False),
                                 read_r=False)

        sd = ed_shutdown(self.ed)
        fl_in.process_close = sd
        fl_out.process_close = sd

        self.stream = EventStreamServer(fl_in, fl_out)
        self.stream.watch_files = self._watch_files
        self._start_watch()
Esempio n. 6
0
 def __init__(self, *args, **kwargs):
    BTControlConnectionClient.__init__(self)
    AsyncDataStream.__init__(self, *args, **kwargs)