Beispiel #1
0
 def set_trace(self, frame=None):
     if frame is None:
         frame = sys._getframe().f_back
     try:
         Pdb.set_trace(self, frame)
     except IOError as exc:
         if exc.errno != errno.ECONNRESET:
             raise
 def set_trace(self, frame=None):
     if frame is None:
         frame = sys._getframe().f_back
     try:
         Pdb.set_trace(self, frame)
     except IOError as exc:
         if exc.errno != errno.ECONNRESET:
             raise
Beispiel #3
0
 def set_trace(self, frame=None):
     if frame is None:
         frame = _frame().f_back
     try:
         Pdb.set_trace(self, frame)
     except socket.error as exc:
         # connection reset by peer.
         if exc.errno != errno.ECONNRESET:
             raise
Beispiel #4
0
 def set_trace(self, frame=None):
     if frame is None:
         frame = _frame().f_back
     try:
         Pdb.set_trace(self, frame)
     except socket.error, exc:
         # connection reset by peer.
         if exc.errno != errno.ECONNRESET:
             raise
Beispiel #5
0
 def set_trace(self, frame=None):
     if self.suspend:
         self.con.acquire()
         try:
             while not self.debugging:
                 self.con.wait()
             self.suspend = False
         finally:
             self.con.release()
     if self.debugging:
         Pdb.set_trace(self, frame=frame)
Beispiel #6
0
 def set_trace(self, frame=None):
     if self.suspend:
         self.con.acquire()
         try:
             while not self.debugging:
                 self.con.wait()
             self.suspend = False
         finally:
             self.con.release()
     if self.debugging:
         Pdb.set_trace(self, frame=frame)
Beispiel #7
0
def ddb(rank=0):
    """
    Distributed Debugger that will insert a py debugger on rank `rank` and
    pause all other distributed processes until debugging is complete.
    :param rank:
    """
    if torch.distributed.get_rank() == rank:
        from pdb import Pdb
        pdb = Pdb(skip=["torch.distributed.*"])
        pdb.set_trace(sys._getframe().f_back)
    torch.distributed.barrier()
Beispiel #8
0
    def set_trace(self, *args, **kwargs):
        """Start a pdb debugger available via telnet, and optionally email people the endpoint

        The endpoint will always be seen in the py.test runner output.

        Keyword Args:
            recipients: A list where, if set, an email will be sent to email addresses
                in this list.
            subject: If set, an optional custom email subject

        """
        host, port = self.sock.getsockname()
        endpoint = 'host {} port {}'.format(store.my_ip_address, port)

        recipients = kwargs.pop('recipients', None)
        if recipients:
            # write and send an email
            subject = kwargs.pop('subject', 'RDB Breakpoint: Manually invoked')
            body = dedent("""\
            A py.test run encountered an error. The remote debugger is running
            on {} (TCP), waiting for telnet connection.
            """).format(endpoint)

            try:
                smtp_server = smtp_conf['server']
                smtp = smtplib.SMTP(smtp_server)
                msg = MIMEText(body)
                msg['Subject'] = subject
                msg['To'] = ', '.join(recipients)
                smtp.sendmail('*****@*****.**', recipients,
                              msg.as_string())
            except socket.error:
                logger.critical("Couldn't send email")

        msg = 'Remote debugger listening on {}'.format(endpoint)
        logger.critical(msg)
        write_line(msg, red=True, bold=True)
        self.sock.listen(1)
        (client_socket, address) = self.sock.accept()
        client_fh = client_socket.makefile('rw')
        Pdb.__init__(self,
                     completekey='tab',
                     stdin=client_fh,
                     stdout=client_fh)
        sys.stdout = sys.stdin = client_fh
        Pdb.set_trace(self, *args, **kwargs)
        msg = 'Debugger on {} shut down'.format(endpoint)
        logger.critical(msg)
        write_line(msg, green=True, bold=True)
Beispiel #9
0
    def set_trace(self, *args, **kwargs):
        """Start a pdb debugger available via telnet, and optionally email people the endpoint

        The endpoint will always be seen in the py.test runner output.

        Keyword Args:
            recipients: A list where, if set, an email will be sent to email addresses
                in this list.
            subject: If set, an optional custom email subject

        """
        host, port = self.sock.getsockname()
        endpoint = 'host {} port {}'.format(store.my_ip_address, port)

        recipients = kwargs.pop('recipients', None)
        if recipients:
            # write and send an email
            subject = kwargs.pop('subject', 'RDB Breakpoint: Manually invoked')
            body = dedent("""\
            A py.test run encountered an error. The remote debugger is running
            on {} (TCP), waiting for telnet connection.
            """).format(endpoint)

            try:
                smtp_server = smtp_conf['server']
                smtp = smtplib.SMTP(smtp_server)
                msg = MIMEText(body)
                msg['Subject'] = subject
                msg['To'] = ', '.join(recipients)
                smtp.sendmail('*****@*****.**', recipients, msg.as_string())
            except socket.error:
                logger.critical("Couldn't send email")

        msg = 'Remote debugger listening on {}'.format(endpoint)
        logger.critical(msg)
        write_line(msg, red=True, bold=True)
        self.sock.listen(1)
        (client_socket, address) = self.sock.accept()
        client_fh = client_socket.makefile('rw')
        Pdb.__init__(self, completekey='tab', stdin=client_fh, stdout=client_fh)
        sys.stdout = sys.stdin = client_fh
        Pdb.set_trace(self, *args, **kwargs)
        msg = 'Debugger on {} shut down'.format(endpoint)
        logger.critical(msg)
        write_line(msg, green=True, bold=True)
Beispiel #10
0
def set_trace(timeout=5 * 60):
    server_thread = threading.Thread(target=server_thread_start,
                                     kwargs={'timeout': timeout},
                                     daemon=True)
    server_thread.start()

    class DebuggerInput:
        def readline(self):
            return input_queue.get()

    class DebuggerOutput:
        def write(self, string):
            output_queue.put(string)

        def flush(self):
            pass

    debugger = Pdb(
        stdin=DebuggerInput(),
        stdout=DebuggerOutput(),
        skip=['ngrok_pdb'],
        nosigint=True,
    )
    debugger.set_trace(frame=sys._getframe().f_back)
Beispiel #11
0
class TestCaseBase(unittest.TestCase):
    """Base class for all other test classes to use"""
    def setUp(self):
        # Keep Debugger close at hand
        self.pdb = Pdb()

    def trace(self):
        """Enter the pdb debugger, 'n' will step back to self.trace() caller"""
        return self.pdb.set_trace()

    def subtests(self, items):
        """
        Return each item's value inside an active context manager

        :param tuple items: Tuple or list of items to create contexts for
        :returns: Each item's value inside an active context manager
        :rtype: type(item)
        """
        for item in items:
            ctxmgr = self.subTest(item=item)
            with ctxmgr:
                yield item
Beispiel #12
0
 def set_trace(self, frame=None):
     if frame is None:
         frame = _frame().f_back
     Pdb.set_trace(self, frame)
Beispiel #13
0
		super(GeometryLineString, self).__init__(name, **facets)


class GeometryPolygon(_Type):
	def __init__(self, name, **facets):
		super(GeometryPolygon, self).__init__(name, **facets)


class GeometryMultiPoint(_Type):
	def __init__(self, name, **facets):
		super(GeometryMultiPoint, self).__init__(name, **facets)


class GeometryMultiLineString(_Type):
	def __init__(self, name, **facets):
		super(GeometryMultiLineString, self).__init__(name, **facets)


class GeometryMultiPolygon(_Type):
	def __init__(self, name, **facets):
		super(GeometryMultiPolygon, self).__init__(name, **facets)


class GeometryCollection(_Type):
	def __init__(self, name, **facets):
		super(GeometryCollection, self).__init__(name, **facets)

s = String("foo", Unicode = True, MaxLength=13)
node =  s.meta_node
debugger.set_trace()
Beispiel #14
0
 def set_trace(self, frame=None):
     if frame is None:
         frame = _frame().f_back
     with ignore_errno(errno.ECONNRESET):
         Pdb.set_trace(self, frame)
Beispiel #15
0
 def set_trace(self, frame=None):
     if frame is None:
         frame = _frame().f_back
     with ignore_errno(errno.ECONNRESET):
         Pdb.set_trace(self, frame)
Beispiel #16
0
 def set_trace(self, frame=None):
     if frame is None:
         frame = _frame().f_back
     Pdb.set_trace(self, frame)