ununderstandable behavior subprocess.Popen(cmd,stdout) and os.system(cmd)

拟墨画扇 提交于 2020-01-06 09:03:29

问题


I use an external command inside a python script using firstly:

subprocess.Popen(cmd, stdout=subprocess.PIPE)

then i get the stdout.

The problem is that the result of this external command when executing it inside the script is not the same if i execute it directly in the command line.

I use then os.system(cmd), but the same problem.

Is this instructions in python use some buffers?

How can i explain the difference between the two results (command line and inside the script).

I'm using this tool as a local command from comman line after installing it:

https://potassco.org/clingo/run/

I use some file as input like this one:

edge("s1","s3").

edge("s2","s4").

edge("s3","s4").

path(X,Y) :- edge(X,Y). % x and y are strings

path(X,Z) :- path(X,Y), path(Y,Z).

:- path(X,Y), path(Y,X). %cyclic path.

To do it the tool generate a model like this :

edge("s1","s3") edge("s2","s4") edge("s3","s4") path("s1","s3") path("s2","s4") path("s3","s4") path("s1","s4")
SATISFIABLE

When i call the command inside my python script it doesn't compute all the model, it generate an incomplete model. This problem appear only in the big examples, which requires the computation of a large model . That's why i'm asking if this commands : subprocess.Popen and os.system use some buffers...

来源:https://stackoverflow.com/questions/52394697/ununderstandable-behavior-subprocess-popencmd-stdout-and-os-systemcmd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!