• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem calling python script from java.

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Henry.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks winston and richard.
Article what you have posted helped me a lot.
reply
    Bookmark Topic Watch Topic
  • New Topic