Пример #1
0
    def __init__(self, stream, timeout=None, **kwargs):
        StreamIO.__init__(self)
        self.stream = stream
        self.session = stream.session
        self.timeout = timeout if timeout else self.session.options.get("stream-timeout")
        self.buffer = None

        if logger.root.level <= logger.DEBUG:
            websocket.enableTrace(True, log)
Пример #2
0
    def __init__(self, stream, timeout=None):
        StreamIO.__init__(self)
        self.session = stream.session
        self.stream = stream

        if not timeout:
            timeout = self.session.options.get("stream-timeout")

        self.timeout = timeout
Пример #3
0
 def copy_to_pipe(stream: StreamIO, pipe: NamedPipeBase, chunk_size):
     log.debug(f"Starting copy to pipe: {pipe.path}")
     pipe.open()
     while not stream.closed:
         try:
             data = stream.read(chunk_size)
             if len(data):
                 pipe.write(data)
             else:
                 break
         except OSError:
             log.error(f"Pipe copy aborted: {pipe.path}")
             break
     try:
         pipe.close()
     except OSError:  # might fail closing, but that should be ok for the pipe
         pass
     log.debug(f"Pipe copy complete: {pipe.path}")