0

I have Xampp with PHP7.4.18 installed, and trying to execute curl in separate thread, to prevent blocking website runtime. Installed regarding those instructions: https://stackoverflow.com/a/70193902/2599826

php -v

PHP 7.4.18 (cli) (built: Apr 27 2021 17:17:20) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

used this file php_parallel-1.1.4-7.4-ts-vc15-x64.zip

in <? phpinfo() i see:

parallel
parallel support    enabled
parallel version    1.1.4

This is my code

<?php
$runtime = new \parallel\Runtime();

$future = $runtime->run(function(){
    for ($i = 0; $i < 50; $i++)
        echo "$i";
        
    return "easy";
});

for ($i = 0; $i < 50; $i++) {
    echo ".";
}

When I refresh page, in browser i'm getting

This site can’t be reached
The connection was reset.

php/apache error logs are empty

  • Usually, multi-threading would be for handling separate request for different users. In your case, you are trying to executing curl in a separate thread from the thread processing user requests. How do you ensure inter-thread communication? – Udo E. Apr 11 '22 at 16:49
  • I'm planning to write session (if $_SESSION variable shared between threads) or will update mysql database when curl request will finish, and get result with ajax request, when i'll need this in on the webpage. – user2599826 Apr 11 '22 at 17:34

0 Answers0