amp
amp copied to clipboard
32 bit PHP: Return value of Amp\Loop\NativeDriver::now() must be of the type int, float returned
Got this error:
Return value of Amp\Loop\NativeDriver::now() must be of the type int, float returned
#0 vendor/amphp/amp/lib/Loop/NativeDriver.php(130): Amp\Loop\NativeDriver->now() #1 vendor/amphp/amp/lib/Loop/Driver.php(138): Amp\Loop\NativeDriver->dispatch() #2 vendor/amphp/amp/lib/Loop/Driver.php(72): Amp\Loop\Driver->tick() #3 vendor/amphp/amp/lib/Loop.php(95): Amp\Loop\Driver->run()
version: v2.6.2
PHP 7.4.30 (cli) (built: Jul 7 2022 15:51:43) ( NTS )
Thanks, Flavio
Are you running on a 32-bit install of PHP?
If so, I would have expected some warnings from https://github.com/amphp/amp/blob/c5ea79065f98f93f7b16a4d5a504fe5d69451447/lib/Internal/functions.php#L81-L85
Thanks, good to know. Yes, it's a 32bit OS running on an RPI4. It's a long running process, I will restart it regularly.
@flaviobattimo I haven't been able to test this warning, as I don't have any 32 bit system available. Could you please check whether warnings are enabled in your error reporting settings and check the log? It'd be helpful to know the warning works as expected.
I can't find any warning in the logs, but they might be disabled. Instead of a warning, a method to check when to restart the process could be useful. But I understand 32 bit systems are almost gone.
O erro indica que o método now() da classe NativeDriver do Amp\Loop está retornando um valor que não é um inteiro ou um número em ponto flutuante (float). Para resolver esse problema, você pode verificar a implementação do método now() na classe NativeDriver e garantir que ele sempre retorne um valor do tipo int ou float. Outra opção é atualizar a versão do amphp/amp para a versão mais recente, que pode ter corrigido esse problema. Certifique-se de verificar a documentação e os requisitos de atualização antes de atualizar sua versão. Se a atualização não for possível ou não resolver o problema, você também pode tentar utilizar um driver diferente no Amp\Loop. Existem vários drivers disponíveis que podem ser usados em vez do NativeDriver. Por fim, se você não conseguir resolver o problema, pode ser útil entrar em contato com a comunidade do amphp/amp.