xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2448: temporary-main-loop.patch

File temporary-main-loop.patch, 1.9 KB (added by totaamwin32, 2 years ago)

possible fix

  • xpra/net/ssh.py

     
    6767            env = os.environ.copy()
    6868            env["XPRA_LOG_TO_FILE"] = "0"
    6969            kwargs["env"] = env
    70         proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, **kwargs)
     70        proc = Popen(cmd, stdout=PIPE, stderr=PIPE, **kwargs)
     71        stdout = []
     72        stderr = []
     73        from gi.repository import Gtk
     74        def read_thread(fd, out):
     75            while proc.poll() is None:
     76                try:
     77                    v = fd.read()
     78                    if v:
     79                        out.append(v)
     80                except:
     81                    time.sleep(0.1)
     82            try:
     83                Gtk.main_quit()
     84            except:
     85                pass
     86        from xpra.make_thread import start_thread
     87        start_thread(read_thread, "dialog-stdout-reader", True, (proc.stdout, stdout))
     88        start_thread(read_thread, "dialog-stderr-reader", True, (proc.stderr, stderr))
    7189        if is_WSL():
    72             #WSL needs to wait before calling communicate?
     90            #WSL needs to wait before calling communicate,
     91            #is still needed now that we read from a thread?
    7392            proc.wait()
    74         stdout, stderr = proc.communicate()
     93        Gtk.main()
    7594        log("exec_dialog_subprocess(%s) returncode=%s", cmd, proc.poll())
    7695        if stderr:
    7796            log.warn("Warning: dialog process error output:")
    78             for x in stderr.decode().splitlines():
     97            for x in (b"".join(stderr)).decode().splitlines():
    7998                log.warn(" %s", x)
    80         return proc.returncode, stdout
     99        return proc.returncode, (b"".join(stdout)).decode()
    81100    except Exception as e:
    82101        log("exec_dialog_subprocess(..)", exc_info=True)
    83102        log.error("Error: failed to execute the dialog subcommand")