Re: Difference between the keywords "run" and "start process" in operationSystem liberary?

1,320 views
Skip to first unread message

Skip Huffman

unread,
Feb 8, 2013, 11:19:29 AM2/8/13
to 陈伟琳, robotframework-users
Have you tried running this outside of robot framework?  Does it keep running if you just start it from the command line?  (Adding robotframework-users back into the email)


On Thu, Feb 7, 2013 at 9:57 PM, 陈伟琳 <cwl...@gmail.com> wrote:
Hi Skip:
Thanks for your reply.
My first doubt is time out.
My script will sleep 3 seconds between each two counts.So I decrease the sleep time to 2 seconds to test. If there is something timeout, I suppose the script can write more lines into log file than before when it sleeps less.
But the result is still the same:stop after 170 counts.
Seems it matters with the lines written into file? But I checked the logging library, using FileHandler, the file size is unlimited.
And it cannot explain why the script can run smoothly with "run" keyword...

I'm not very familar with linux shell.I just can image some limitation exist in shell execution and I just don't know?

2013/2/7 Skip Huffman <skiph...@gmail.com>
Is something timeing out?


On Thu, Feb 7, 2013 at 2:40 AM, Caramel <cwl...@gmail.com> wrote:
Hi:

I have a python script which runs on linux , periodically counts records number in a DB table and write the result into a log file through python logging library functions.It will only stop counting after the record number becomes 0.It works quite well alone.
Now I want to put the script directly into my robot framework case. 
But I find when I use "start process|python myscript.py", it always stops writing log file in the middle  (170 counts in my last run), though the script is still running and there are still records in the DB table.
When I use “run|python myscript.py", everything is OK.

As my previous comprehension, the difference of "run" and "start process" is that the former will wait for the execution to over, while the latter won't.
Am I wrong? Can anyone give me a clue?

Thanks.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Skip Huffman
Senior Software Engineer in Test/Continuous Integration



--
On whom the moon doth shine



--
Skip Huffman
Senior Software Engineer in Test/Continuous Integration

Pekka Klärck

unread,
Feb 18, 2013, 4:41:14 PM2/18/13
to cwl...@gmail.com, robotframe...@googlegroups.com
2013/2/7 Caramel <cwl...@gmail.com>:
>
> I have a python script which runs on linux , periodically counts records
> number in a DB table and write the result into a log file through python
> logging library functions.It will only stop counting after the record number
> becomes 0.It works quite well alone.
> Now I want to put the script directly into my robot framework case.
> But I find when I use "start process|python myscript.py", it always stops
> writing log file in the middle (170 counts in my last run), though the
> script is still running and there are still records in the DB table.
> When I use “run|python myscript.py", everything is OK.

Does your script create lot of output into stdout and/or stderr? That
could fill up output buffers of the process and prevent it from
continuing further. You could try redirecting stdout and/or stderr
into some file (or /dev/null if you aren't interested about the
output) and see does that help.

> As my previous comprehension, the difference of "run" and "start process" is
> that the former will wait for the execution to over, while the latter won't.
> Am I wrong? Can anyone give me a clue?

Yes, this is the main difference between Run and Start Process. They
are also implemented differently (the former uses os.popen and the
latter subprocess.Popen) and may thus behave differently in some
special cases.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

陈伟琳

unread,
Feb 19, 2013, 8:42:04 PM2/19/13
to robotframe...@googlegroups.com
Forget to add the robotframework-users group to the thread..
Thanks all!

---------- Forwarded message ----------
From: 陈伟琳 <cwl...@gmail.com>
Date: 2013/2/19
Subject: Re: Difference between the keywords "run" and "start process" in operationSystem liberary?
To: Pekka Klärck <pe...@iki.fi>


Hi Pekka:

I checked my script again and found a "print" statement used for debug purpose. I commented it and tried again.
Now the script can write file until it ends normally.
So it seems the reason is buffer...
But I still don't understand why using "run" keyword has no such problem.
I should have a study on subprocess + buffer then,:)

Thanks very much!

2013/2/19 Pekka Klärck <pe...@iki.fi>
--
On whom the moon doth shine

Kevin O.

unread,
Feb 19, 2013, 11:12:41 PM2/19/13
to robotframe...@googlegroups.com
FYI you can run into the same issue in Java. Groovy has nice augmentations to the Process class to avoid

def stdout = new StringBuffer()
def stderr = new StringBuffer()
Process p = "somecommand".execute()
p.consumeProcessOutput(stdout, stderr)
p.waitFor()

Reply all
Reply to author
Forward
0 new messages