# Path: PyDevRemoteDebug/ptvsd-4.1.3/ptvsd/socket.py
# class TimeoutError(socket.timeout):
#     """A socket timeout happened."""
# 
# @contextlib.contextmanager
# def convert_eof():
#     """A context manager to convert some socket errors into EOFError."""
#     try:
#         yield
#     except ConnectionResetError:
#         raise EOFError
#     except BrokenPipeError:
#         raise EOFError
#     except OSError as exc:
#         if exc.errno in EOF:
#             raise EOFError
#         raise


import errno
import itertools
import json
import os
import os.path
import sys
import time
import traceback
            import thread
            import _thread as thread
from socket import create_connection
from .socket import TimeoutError, convert_eof
    from encodings import ascii

                seq=next(self.__seq),
                request_seq=int(request.get('seq', 0)),
                success=success,
                command=request.get('command', ''),
                message=message or '',
                body=kwargs,
            )

    def set_exit(self):
        # TODO: docstring
        self.__exit = True

    def process_messages(self):
        # TODO: docstring
        if self._timeout is not None:
            self._fail_after = time.time() + self._timeout
        while not self.__exit:
            try:
                self.process_one_message()
                _trace('self.__exit is ', self.__exit)
            except Exception:
                if not self.__exit:
                    raise
                # TODO: log the error?

    def process_one_message(self):
        # TODO: docstring
        try:
            msg = self.__message.pop(0)
        except IndexError:

# Path: PyDevRemoteDebug/ptvsd-4.1.3/ptvsd/socket.py
# class TimeoutError(socket.timeout):
#     """A socket timeout happened."""
# 
# @contextlib.contextmanager
# def convert_eof():
#     """A context manager to convert some socket errors into EOFError."""
#     try:
#         yield
#     except ConnectionResetError:
#         raise EOFError
#     except BrokenPipeError:
#         raise EOFError
#     except OSError as exc:
#         if exc.errno in EOF:
#             raise EOFError
#         raise


# Path: PyDevRemoteDebug/ptvsd-4.1.3/ptvsd/ipcjson.py
import errno
import itertools
import json
import os
import os.path
import sys
import time
import traceback
            import thread
            import _thread as thread
from socket import create_connection
from .socket import TimeoutError, convert_eof
    from encodings import ascii

                seq=next(self.__seq),
                request_seq=int(request.get('seq', 0)),
                success=success,
                command=request.get('command', ''),
                message=message or '',
                body=kwargs,
            )

    def set_exit(self):
        # TODO: docstring
        self.__exit = True

    def process_messages(self):
        # TODO: docstring
        if self._timeout is not None:
            self._fail_after = time.time() + self._timeout
        while not self.__exit:
            try:
                self.process_one_message()
                _trace('self.__exit is ', self.__exit)
            except Exception:
                if not self.__exit:
                    raise
                # TODO: log the error?

    def process_one_message(self):
        # TODO: docstring
        try:
            msg = self.__message.pop(0)
        except IndexError:

            with convert_eof():
