Re: [PHP] running python in php timeout



2008/12/29 brad <bradcausey@xxxxxxxxx>:
Hi,

I'm executing a python script from php that runs quite a long time (15+
minutes) and ends up timing out. Is there a way I can execute the python
code and move on executing the remaining php code on the page?
Thanks!

Hi Brad,

It's a little tough to say for sure since you didn't specify your OS
or platform (always good info to include), but if you're on *nix then
you'll need to tell the child process to run in the background and
redirect the output from the child process to somewhere else (say, a
log file). You also didn't say how you're executing the child process,
but here's a common way to do it using backticks:

`/path/to/executable "$arg1" "$arg2" >> /path/to/logfile.log 2>&1 &`

The '>> /path/to/logfile.log' redirects standard output from the
process to your log file. The '2>&1' following that redirects the
process's standard error to its standard output (which means that
error messages will also be written to the log file), and the final
ampersand puts the child process into the background.

The same technique also works with exec() etc.


Torben
.



Relevant Pages

  • Re: forking in c
    ... each child process should have a child process of their own. ... > meanwhile the parent process will have a childpid greater then 0 and it will ... Outside of failures in fork(), the parent /is/ creating new child processes ... continues executing from the first fork ...
    (comp.unix.programmer)
  • Re: forking in c
    ... each child process should have a child process of their own. ... > meanwhile the parent process will have a childpid greater then 0 and it will ... Outside of failures in fork(), the parent /is/ creating new child processes ... continues executing from the first fork ...
    (comp.lang.c)
  • Re: Possible to execute another program and capture its stdout in C?
    ... Nathan Mates wrote: ... line for executing another program, and I need to be able to "capture" the stdout from that other program for processing in my app. ... // Write to the pipe that is the standard input for a child process. ...
    (microsoft.public.vc.language)
  • Re: how many times the printf will be executed ?
    ... In any given instance of the program printf will be executed once. ... Ask the question on a relevant forum. ... child process leaving behind the main... ... child process is executing then in that case you have printf executed ...
    (comp.lang.c)
  • Re: How can I instruct TCL to display real-time subprocess information to the shell?
    ... seeing is the inability to run a child process where the executable ... This deletes the fileevent. ... Calling RunSynplifyPro results in: ... while executing ...
    (comp.lang.tcl)