Cmd Prompt Tests -> Multiple Commands Session
Idan U.
Rishon-letzion,

Sep 16, 2019
17 Posts

0  |  0  

Re: Cmd Prompt Tests -> Multiple Commands Session

Hello,

Running this test from the example folder with cmd.exe is working fine but when i try to run is with python "StdIOProcess Read(s)" hang and i have to force close Ateasy.

Is there  a way to run multiple commands with python ?

My code:

StdIOProcess Execute("py.exe", "", "", false)
StdIOProcess Read(s)
append s;
StdIOProcess Write("print(\"this is a test1\")")
StdIOProcess Read(s)
append s;
StdIOProcess Write("print(\"this is a test2\")")
StdIOProcess Read(s)
append s;

Tero S.
Irvine, CA

Sep 19, 2019
16 Posts

0  |  0  

Re: Cmd Prompt Tests -> Multiple Commands Session

Hi Idan,

To pass arguments to an ATEasy application, compile your ATEasy project to an executable and from the command line you should be able to use standard input like:
myExe inputArg inputArg1 inputArg2 etc...

If you want to run StdIoProcess commands from Python, you would need to compile the ATEasy driver to a DLL and import it in Python. Here is a Knowledge Base article to help you with compiling the DLL:
https://www.marvintest.com/KnowledgeBase/KBArticle.aspx?ID=215
And the relevant Python documentation to load the DLL:
https://docs.python.org/3.3/library/ctypes.html

One reason for hanging the Read -command involves synchronous read while data is not available. You could try setting StdIoProcess variable m_bAsync to True instead of its default False. Let me know how it goes.

Regards,
Tero

Idan U.
Rishon-letzion,

Sep 23, 2019
17 Posts

0  |  0  

Re: Cmd Prompt Tests -> Multiple Commands Session

Hello Tero,

I need to execute a python process and keep it alive through my tests since i need to initialize all the objects of the test equipment.
For now i see how ATEasy can do this, it seams that the python integration of ATEasy is not complete.

To bypass this the STDIO process is running a python script in "while true" mode that wait for my trier of the tests and for some reason after several test ATEasy hang

The test do NOTHING for now just create some files write random numbers and send "pass" back.

Tried to work with sync and a-sync methods  

Please advise.
BR,
idan.

Solution Available
Tero S.
Irvine, CA

Oct 1, 2019
16 Posts

1  |  0  

Re: Cmd Prompt Tests -> Multiple Commands Session

Hi Idan,

There are definitely plenty of ways deadlock a process. ATEasy StdIoProcess Windows DLLs like System.IO StreamReader/StreamWriter to work with standard IO. These facilities are fairly robust. Depending on what Python packages you are using, the most common issues revolve around a congested buffer, undhandled event or maybe writing to an unbuffered standard error stream. For example, the Logging facility for Python is fairly popular and uses classes like StreamHandler to output to streams. Interestingly enough if you choose no argument when you instantiate your handler like:
logging.StreamHandler()
the default you may end up with is the standard error pipe.

With that default it is possible that a process can hang while the standard error stream is not completely buffered: then, asynchronous read is not necessarily signaled unless instructed by you to do so, and synchronous read may wait forever for standard input which may never come in this case. So, this scenario is one possible reason for a hung procedure, and I think you should try to rule it out first if possible. In order to do that, you could try to setup StreamHandler with for example sys.stdout for standard output to redirect to standard output stream instead of standard error and then check for congruence in ATEasy.

If you have a more specific question in mind, you can also include some pertinent/suspicious code in the forum, and I'll look at that. Either way, let me know.

Regards,
Tero



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]