471,887 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

File access

JD
Hi,

What I am trying to do is to run a subprocess on another machine using
subprocess.Popen, this subprocess contuinue writing something into a
file when it is runing.

After submit this subprocess, I tried to open the file and readlines()
in the loop (with a delay) in the loop) when the subprocess was
runing.

The problem is I could not get anything untill the subprocess
finished.

I also tried to run another python programm when the subprocess is
runing, I could get what I want.

Does anyone know why? Thanks!

JD

Aug 2 '07 #1
4 1089
On Aug 2, 12:41 pm, JD <Jiandong...@gmail.comwrote:
Hi,

What I am trying to do is to run a subprocess on another machine using
subprocess.Popen, this subprocess contuinue writing something into a
file when it is runing.

After submit this subprocess, I tried to open the file and readlines()
in the loop (with a delay) in the loop) when the subprocess was
runing.

The problem is I could not get anything untill the subprocess
finished.

I also tried to run another python programm when the subprocess is
runing, I could get what I want.

Does anyone know why? Thanks!

JD
Could the problem be that the subprocess only flushes the output
buffer when it terminates, and so until the subprocess "finishes", as
you say, the file is empty because the data is still in the buffer?
Trying throwing some flushes into the code and see if it helps.

Or am I misunderstanding your question?

Aug 2 '07 #2
JD
Thanks for answering,

No, the data was writing into the file when the subprocess was
runing.

For example, every second it will write something into the file.

I tried to run another python program aside and it sucessfully read
the file when the subprocess was runing.

JD

On Aug 2, 11:00 am, Adrian Petrescu <apetr...@uwaterloo.cawrote:
On Aug 2, 12:41 pm, JD <Jiandong...@gmail.comwrote:
Hi,
What I am trying to do is to run a subprocess on another machine using
subprocess.Popen, this subprocess contuinue writing something into a
file when it is runing.
After submit this subprocess, I tried to open the file and readlines()
in the loop (with a delay) in the loop) when the subprocess was
runing.
The problem is I could not get anything untill the subprocess
finished.
I also tried to run another python programm when the subprocess is
runing, I could get what I want.
Does anyone know why? Thanks!
JD

Could the problem be that the subprocess only flushes the output
buffer when it terminates, and so until the subprocess "finishes", as
you say, the file is empty because the data is still in the buffer?
Trying throwing some flushes into the code and see if it helps.

Or am I misunderstanding your question?

Aug 2 '07 #3
JD wrote:
Hi,

What I am trying to do is to run a subprocess on another machine using
subprocess.Popen, this subprocess contuinue writing something into a
file when it is runing.

After submit this subprocess, I tried to open the file and readlines()
in the loop (with a delay) in the loop) when the subprocess was
runing.

The problem is I could not get anything untill the subprocess
finished.

I also tried to run another python programm when the subprocess is
runing, I could get what I want.

Does anyone know why? Thanks!

JD
I believe you are approaching this incorrectly. You should probably be using a
socket server/socket client to communicate between these two. Or perhaps you
could use a multi-user database table. Writing/reading to files from two
different workstations and expecting them to by synchronized most likely won't work.

-Larry
Aug 2 '07 #4
JD
Thanks for the suggestion, I am thinking implement a database system
for that.

JD

On Aug 2, 12:11 pm, Larry Bates <larry.ba...@websafe.comwrote:
JD wrote:
Hi,
What I am trying to do is to run a subprocess on another machine using
subprocess.Popen, this subprocess contuinue writing something into a
file when it is runing.
After submit this subprocess, I tried to open the file and readlines()
in the loop (with a delay) in the loop) when the subprocess was
runing.
The problem is I could not get anything untill the subprocess
finished.
I also tried to run another python programm when the subprocess is
runing, I could get what I want.
Does anyone know why? Thanks!
JD

I believe you are approaching this incorrectly. You should probably be using a
socket server/socket client to communicate between these two. Or perhaps you
could use a multi-user database table. Writing/reading to files from two
different workstations and expecting them to by synchronized most likely won't work.

-Larry

Aug 2 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Joe Costa | last post: by
11 posts views Thread by sur | last post: by
16 posts views Thread by Eran.Yasso | last post: by
5 posts views Thread by =?Utf-8?B?QWRyaWFuTW9ycmlz?= | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.