Calling python from a php script

This is the place for queries that don't fit in any of the other categories.

Calling python from a php script

Postby fbartolom » Wed Feb 05, 2014 4:45 pm

I need to call a simple python script from a php program. And I use the following piece of code to execute it:
Code: Select all
      $pythonCommand="/opt/python3/bin/python3 palina.py $palina";
      $result=exec($pythonCommand);
      //echo "command=$pythonCommand result=$result";
      $resultData = json_decode($result, true);

the python code itself is very simple.
Yet when I run the python script from the command line it is very fast, while if I execute it from inside the php script, the php script gets extremely slow. In one server it even retuns without waiting the python scripts to complete.
The examples are on Debian and CentOS:
http://www.taxiprofessional.net/iPhone/inarrivo/php/waitBusses.php?Index=13582
http://107.150.13.150/iPhone/inarrivo/php/waitBusses.php?Index=13582
Any idea about what it might be and how to fix it?

Thanks.
fbartolom
 
Posts: 15
Joined: Tue Jan 28, 2014 9:30 am

Re: Calling python from a php script

Postby stranac » Wed Feb 05, 2014 6:24 pm

Sounds like a php problem to me...
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1115
Joined: Thu Feb 07, 2013 3:42 pm


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot], stranac and 3 guests