Why doesn't FreeCAD respond in real time?

Need help, or want to share a macro? Post here!
wmayer
Site Admin
Posts: 15471
Joined: Thu Feb 19, 2009 10:32 am

Re: Why doesn't FreeCAD respond in real time?

Postby wmayer » Sat Jul 18, 2015 5:17 pm

True. From the description of subprocess it becomes clear that the output is returned at the end. Maybe a different mechanism like Popen should be used?
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

Re: Why doesn't FreeCAD respond in real time?

Postby django013 » Sun Jul 19, 2015 4:39 am

Hello,

there are 3 FreeCAD.Console.PrintMessage(...) calls - we should not confuse. Also the talking about subprocess might be source of confusion too, as execution of the macro might be a subprocess too (but I don't know that).

To clarify what I'm talking about - here's a code fragment of gmsh.FCMacro

Code: Select all

        options = ' -algo ' + algo + max_size + min_size + cmd_optimize + order + cmd_line_opt
        # RUN GMSH
        command = gmsh_bin + ' ' + temp_file + dim + '-format ' + file_format + ' -o ' + temp_mesh_file  + '' + options
        FreeCAD.Console.PrintMessage("Running: {}".format(command))
        try:
            output = subprocess.check_output([command, '-1'], shell=True, stderr=subprocess.STDOUT,)
            FreeCAD.Console.PrintMessage(output)
...
        except:
            FreeCAD.Console.PrintError("Unexpected error in GMSHMesh macro: {}".format(sys.exc_info()[0]))
So I was talking about the PrintMessage-statement before the "try:" - which tells us about the command, that will be executed.
You both are talking about the PrintMessage statement after the subprocess, which tells the collected result of the subprocess.

So my expectation was, that the output of the first PrintMessage pops up before subprocess execution, where as the second PrintMessage pops up after the subprocess execution.

In my case, the second PrintMessage will never be executed, as subprocess fails, so the PrintMessage after "except" comes into play.

Visual effect - watching console where I started fc in logging mode and output of "tail -f logfile" - is, that the first PrintMessage, which tells about the command to be executed, pops up after termination of subprocess, together with the third PrintMessage after "except".
OS: Linux Debian Jessie amd64 - FC: Git Master