Running a Python script from PHP without waiting for an answer

0

My problem is that I have a WEB page that I must integrate to a Bot in python for each user and make a call to the python bot and that it stays running on the server even when the user has disconnected.

I tried to do it with the shell_exec function from PHP but it hangs PHP waiting for an answer.

I must run the python script on the server from PHP which generates a response that is stored in the database from python.

I currently run the bot manually on the server with the "screen" function so that it runs in the background. but I want to automate the process to be run by pressing a button on my WEB page

I am running in an Ubuntu Server Environment on Apache2. and on the same server I have my Python script that I want to run

    
asked by fernando quero 04.09.2018 в 00:16
source

1 answer

0

You do not specify the operating system, but you must open an asynchronous process with popen (). Assuming you are working with Windows

$command = 'start /b python.exe ruta_del_script.py argumentos_si_los_tiene';
pclose(popen($command, 'r'));

link

    
answered by 04.09.2018 в 00:59