0

I have a script in php that is calling a python one, which is a neural network being trained and it takes about 80 seconds to finish, but my php script finishes fast.

I tried just creating a csv file in python which is a quick process, and it worked, so its really a question of time.

I've already tried using the following code, and it didn't worked.

var_dump(time_sleep_until(microtime(true)+100));

3 Answers 3

1

Just use the Symphony Process component -> https://symfony.com/doc/current/components/process.html

It allows you to run processes asynchronously and check whether they are still running: https://symfony.com/doc/current/components/process.html#running-processes-asynchronously

Cheers.

Sign up to request clarification or add additional context in comments.

Comments

0

Straight from the manual

https://www.php.net/manual/en/function.sleep.php

sleep ( int $seconds ) : int

Delays the program execution for the given number of seconds.

Parameters ¶

seconds Halt time in seconds.

Return Values ¶

Returns zero on success, or FALSE on error.

If the call was interrupted by a signal, sleep() returns a non-zero value. On Windows, this value will always be 192 (the value of the WAIT_IO_COMPLETION constant within the Windows API). On other platforms, the return value will be the number of seconds left to sleep.

Errors/Exceptions ¶

If the specified number of seconds is negative, this function will generate a E_WARNING.

Comments

0

usleep(100); is more intuitive for what you are trying to do than using time_sleep_until, although I believe your time_sleep_until should work pretty similarly. However, the manual for time_sleep_until() seems to suggest that it may not work consistently for short times (such as .2 seconds). I would try usleep instead.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.