简体   繁体   中英

PHP not getting response from python?

Php never get response If calling an API in python and it takes more than 5 minutes. so I was checking with time.sleep(300) in python, but it works.

I do not know why php not getting response from python while calling an API.

CODE

test.php

<?php
  $file_id=1; 
  $response=exec('python /home/xyz/test.py '.$file_id);

  echo $response;

 ?>

test.py

import os, json
import sys


sleep(300)
#sleep(420)
print "hello"

Maybe python is throwing an error and not printing to stdout because of that error. Did you forget to import sleep from the time module, or where does it come from?

It should be:

import time
time.sleep(300)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM