Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

32 bit PHP: Return value of Amp\Loop\NativeDriver::now() must be of the type int, float returned #413

Open
flaviobattimo opened this issue Jan 30, 2023 · 5 comments

Comments

@flaviobattimo
Copy link

flaviobattimo commented Jan 30, 2023

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

@trowski
Copy link
Member

trowski commented Feb 11, 2023

Are you running on a 32-bit install of PHP?

If so, I would have expected some warnings from

\trigger_error(
"getCurrentTime() will overflow in $timeToOverflow seconds, please restart the process before that. " .
"You're using a 32 bit version of PHP, so time will overflow about every 24 days. Regular restarts are required.",
\E_USER_WARNING
);

@flaviobattimo
Copy link
Author

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.

@kelunik
Copy link
Member

kelunik commented Feb 13, 2023

@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.

@flaviobattimo
Copy link
Author

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.

@VictorGSoutoXP
Copy link

VictorGSoutoXP commented May 4, 2023

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.

@kelunik kelunik changed the title Return value of Amp\Loop\NativeDriver::now() must be of the type int, float returned 32 bit PHP: Return value of Amp\Loop\NativeDriver::now() must be of the type int, float returned Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants