title: Running python in background on PHP page wait for responce
body: <p><a href="https://stackoverflow.com/questions/29881180/running-process-in-background-on-hangs-php-page">running process in background on hangs PHP page</a></p>
  
  <p>I did as explained in this above link but it did not work.</p>
  
  <p>Question:</p>
  
  <p>I want to send mail using Python from PHP. When I call Python, my page waits for a response from Python. I want to run Python in the background.</p>
  
  <p>I also redirect Python's response to another location ex: <code>"E:\\nil.txt"</code>, but it still waits for a response. </p>
  
  <p>I am working on Windows 7. My problem is that all the answers I could find were for Linux.</p>
  
  <p>My PHP code:</p>
  
  <pre><code>    public static function callPython($scriptName, $data){
        $path = "C:\\Users\\Aditya\\Desktop\\".$scriptName.".py";
    //$data=array("to"=&gt;$to,"name"=&gt;$name,"headingSection"=&gt;$headingSection,"body"=&gt;$body,"subject"=&gt;$subject);
       $jsonArray = json_encode($data);
       $jsonArray = str_replace('"', '\"', $jsonArray);
       $dir= "E:\\nil.txt";
       $cmd = 'python '.$path.' '.$jsonArray.' &gt;'.$dir.' 2&gt;&amp;1 &amp;';
       var_dump($cmd);
       shell_exec($cmd);
     }
  </code></pre>
  
  <p>If you need my Python script, then I will post it here.</p>