• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem calling python script from java.  RSS feed

 
priyatham suresh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This is priyatham, I am facing issue while calling python script from java code using process.
python script writing data into the four files(logging.txt, text1.txt, text2.txt, text3.txt) each one is 2mb.
It keeps writing logs into the loggin.txt. And python keeps data into the variables while processing the script and write into the corresponding files after completion of logging.

problem: it's stop writing data into the logging file after 60Kb though process is running.

everything is working fine, if the file size is small.
It's working fine if i run the same using command line.

Here is my java code.

Process p = Runtime.getRuntime().exec("python test.py arg1 arg2 arg3 arg4"); // i replaced the string with "nohup python test.py arg1 arg2 arg3 arg4"
if(p.waitFor() == 0){
System.out.println("process completed.");
}

Thanks in advance for helping me to resolve this problem.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is not really related to threads and synchronization. Moving topic to the Java in General forum.

Henry
 
priyatham suresh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to code ranch.
How can i move my topic from Threads and Synchronization to java in general.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
priyatham suresh wrote:I am new to code ranch.
How can i move my topic from Threads and Synchronization to java in general.


I already moved the topic for you. When I said "moving topic to the Java in General forum", I was just stating what I was doing. I was not asking you to do it.


To answer your question... Only moderators can move topics between forums.

Henry
 
priyatham suresh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
priyatham suresh wrote:I am facing issue while calling python script from java code using process.
..
problem: it's stop writing data into the logging file after 60Kb though process is running.

everything is working fine, if the file size is small. It's working fine if i run the same using command line.

TBH, I can't see anything drastically wrong with what you've posted, but I'm not a Runtime.exec() expert (or fan). I am pretty sure, however, that it's not quite as simple as it looks .

You might want to read this article and see if it raises any flags.

Winston
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
priyatham suresh wrote:
problem: it's stop writing data into the logging file after 60Kb though process is running.



This is most probably the result of a deadlock caused by the process stdout or stderr buffer becoming full and your code doing nothing to remove the data from the buffers. This is one of the prime problems highlighted in the 'traps' article - http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html .
 
priyatham suresh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks winston and richard.
Article what you have posted helped me a lot.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!