Example #1
0
    def loop(self):
        """The dispatch loop."""

        start = time.time()
        while self.socket_map:
            nbsock = self.nbserver.netbeans
            # start the debugger
            if start is not False:
                if time.time() - start > CONNECTION_TIMEOUT:
                    raise IOError(CONNECTION_ERROR % str(CONNECTION_TIMEOUT))
                if nbsock and nbsock.ready:
                    start = False
                    info(nbsock)
                    nbsock.set_debugger(self.debugger)

                    # can daemonize now, no more critical startup errors to
                    # print on the console
                    if self.options.daemon:
                        daemonize()
                    version = __tag__
                    if __changeset__:
                        version += '.' + __changeset__
                    info('pyclewn version %s and the %s debugger',
                                        version, self.clazz.__name__)

            # instantiate a new debugger
            elif nbsock and self.debugger.closed and nbsock.connected:
                self.debugger = self.clazz(self.options)
                nbsock.set_debugger(self.debugger)
                info('new "%s" instance', self.clazz.__name__.lower())

            timeout = self.debugger._call_jobs()
            evtloop.poll(self.socket_map, timeout=timeout)

        self.debugger.close()
Example #2
0
    def interaction(self, frame, traceback):
        """Handle user interaction in the asyncore loop."""
        # wait for the netbeans session to be established
        while not self.started or not self.stop_loop:
            if self.let_target_run:
                return
            time.sleep(debugger.LOOP_TIMEOUT)

        # switch nbsock to the main thread asyncore loop
        self.clt_sockmap = self.switch_map(self.socket_map)
        assert self.clt_sockmap is not None
        os.write(self.ping_w, 'ping\n')

        self.setup(frame, traceback)
        if self.trace_type or self.doprint_trace:
            if self.get_console().timed_out:
                self.console_print('\n')
            if self.trace_type:
                self.console_print(self.trace_type + '\n')
            if traceback:
                self.print_stack_trace()
            else:
                self.print_stack_entry(self.stack[self.curindex])
        self.trace_type = ''
        self.doprint_trace = False

        self.hilite_frame()
        self.stop_loop = False
        self.do_prompt()

        try:
            while not self.stop_loop and self.started:
                try:
                    if self.cmdqueue:
                        self.do_line_cmd(self.cmdqueue.pop(0))
                    else:
                        evtloop.poll(self.socket_map, debugger.LOOP_TIMEOUT)
                except KeyboardInterrupt:
                    # ignore a KeyboardInterrupt to avoid breaking
                    # the debugging session
                    self.console_print('\nIgnoring a KeyboardInterrupt.\n')
                    self.do_prompt()
            self.show_frame()
            self.forget()
        finally:
            # switch nbsock to the clewn thread asyncore loop
            self.switch_map(self.clt_sockmap)
            os.write(self.ping_w, 'ping\n')
Example #3
0
    def loop(self):
        """The dispatch loop."""

        start = time.time()
        nbsock = None
        while True:
            # start the debugger
            if start is not False:
                if time.time() - start > CONNECTION_TIMEOUT:
                    raise IOError(CONNECTION_ERROR % str(CONNECTION_TIMEOUT))
                nbsock = self.nbserver.netbeans
                if nbsock and nbsock.ready:
                    start = False
                    info(nbsock)
                    nbsock.set_debugger(self.debugger)

                    # can daemonize now, no more critical startup errors to
                    # print on the console
                    if self.options.daemon:
                        daemonize()
                    version = __tag__
                    if __changeset__:
                        version += '.' + __changeset__
                    info('pyclewn version %s and the %s debugger', version,
                         self.clazz.__name__)
            elif nbsock.connected:
                # instantiate a new debugger
                if self.debugger.closed:
                    self.debugger = self.clazz(self.options)
                    nbsock.set_debugger(self.debugger)
                    info('new "%s" instance', self.clazz.__name__.lower())
            else:
                if not self.debugger.started or self.debugger.closed:
                    break

            timeout = self.debugger._call_jobs()
            evtloop.poll(self.socket_map, timeout=timeout)

        self.debugger.close()
Example #4
0
    def run_pdb(self):
        """Run the clewn pdb thread."""
        pdb = self.debugger

        # do not start vim
        self.options.editor = ''
        self.setup(False)
        pdb.thread = threading.currentThread()
        pdb.clewn_thread_ident = thread.get_ident()

        pdb.started_event.set()
        last_nbsock = None
        session_logged = True
        while self.socket_map:
            nbsock = self.nbserver.netbeans
            # a new netbeans connection, the server has closed last_nbsock
            if nbsock != last_nbsock and nbsock.ready:
                info(nbsock)
                nbsock.set_debugger(pdb)
                if last_nbsock is None:
                    version = __tag__
                    if __changeset__:
                        version += '.' + __changeset__
                    info('pyclewn version %s and the %s debugger',
                                        version, self.clazz.__name__)
                last_nbsock = nbsock
                session_logged = False

            # log the vim instance
            if not session_logged and nbsock and not nbsock.connected:
                session_logged = True
                debug('Vim instance: ' + str(self))

            timeout = pdb._call_jobs()
            evtloop.poll(self.socket_map, timeout=timeout)

        self.shutdown()
Example #5
0
    def run_pdb(self):
        """Run the clewn pdb thread."""
        pdb = self.debugger

        # do not start vim
        self.options.editor = ''
        self.setup(False)
        pdb.thread = threading.currentThread()
        pdb.clewn_thread_ident = thread.get_ident()

        pdb.started_event.set()
        last_nbsock = None
        session_logged = True
        while self.socket_map:
            nbsock = self.nbserver.netbeans
            # a new netbeans connection, the server has closed last_nbsock
            if nbsock != last_nbsock and nbsock.ready:
                info(nbsock)
                nbsock.set_debugger(pdb)
                if last_nbsock is None:
                    version = __tag__
                    if __changeset__:
                        version += '.' + __changeset__
                    info('pyclewn version %s and the %s debugger', version,
                         self.clazz.__name__)
                last_nbsock = nbsock
                session_logged = False

            # log the vim instance
            if not session_logged and nbsock and not nbsock.connected:
                session_logged = True
                debug('Vim instance: ' + str(self))

            timeout = pdb._call_jobs()
            evtloop.poll(self.socket_map, timeout=timeout)

        self.shutdown()