Beispiel #1
0
    def handle_read(self):
        try:
            moredata = self.recv(16384)
        except socket.error as e:
            if e.errno == errno.EAGAIN:
                return
            raise

        if not moredata:
            self.close()
            return

        stats.global_stats.server_rx_bytes += len(moredata)

        data = self.partial_line + moredata
        lines = data.split(b'\n')
        for line in lines[:-1]:
            try:
                self.process_line(line.decode('ascii'))
            except IOError:
                raise
            except Exception:
                util.log_exc('Unexpected exception processing adept message')

        self.partial_line = lines[-1]
Beispiel #2
0
    def handle_read(self):
        try:
            moredata = self.recv(16384)
        except socket.error as e:
            if e.errno == errno.EAGAIN:
                return
            raise

        if not moredata:
            self.close()
            return

        stats.global_stats.server_rx_bytes += len(moredata)

        data = self.partial_line + moredata
        lines = data.split(b'\n')
        for line in lines[:-1]:
            try:
                self.process_line(line.decode('ascii'))
            except IOError:
                raise
            except Exception:
                util.log_exc('Unexpected exception processing adept message')

        self.partial_line = lines[-1]
Beispiel #3
0
    def handle_error(self):
        t, v, tb = sys.exc_info()
        if isinstance(v, IOError):
            log("Connection to {host}:{port} lost: {ex!s}", host=self.host, port=self.port, ex=v)
        else:
            log_exc("Unexpected exception on connection to {host}:{port}", host=self.host, port=self.port)

        self.handle_close()
Beispiel #4
0
    def handle_error(self):
        t, v, tb = sys.exc_info()
        if isinstance(v, IOError):
            log('Connection to {host}:{port} lost: {ex!s}',
                host=self.host,
                port=self.port,
                ex=v)
        else:
            log_exc('Unexpected exception on connection to {host}:{port}',
                    host=self.host,
                    port=self.port)

        self.handle_close()
Beispiel #5
0
    udp_transport = UdpServerConnection(udp_host, udp_port, udp_key)
    log("Using UDP transport to {host} port {port}",
        host=udp_host,
        port=udp_port)

    receiver = options.build_receiver_connection(args)
    adept = AdeptConnection(udp_transport,
                            allow_anon=args.allow_anon_results,
                            allow_modeac=args.allow_modeac_results)
    outputs = options.build_outputs(args)

    coordinator = Coordinator(receiver=receiver,
                              server=adept,
                              outputs=outputs,
                              freq=options.clock_frequency(args),
                              allow_anon=args.allow_anon_results,
                              allow_modeac=args.allow_modeac_results)
    adept.start(coordinator)
    coordinator.run_until(lambda: adept.closed)


if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        log("Exiting on SIGINT")
    except Exception:
        log_exc("Exiting on exception")
    else:
        log("Exiting on connection loss")