Hearbeat timeout and non-async Mojo action #1815
Replies: 2 comments 3 replies
-
Why would the docs lie? |
Beta Was this translation helpful? Give feedback.
-
In Mojolicious, web applications are necessarily asynchronous by nature. The fact that you can run blocking code on them is a natural result of how Perl operates, namely that there aren't non-blocking versions of each function. As a result, in your web application, even if you write synchronous code, you must be sure to allow your application the time it needs to heartbeat. If that means unblocking something long-running by using subprocess, using a timer rather than sleep, or increasing the heartbeat timeout to accomodate, that is up to you to do. |
Beta Was this translation helpful? Give feedback.
-
The documentation
https://docs.mojolicious.org/Mojolicious/Guides/FAQ#What-does-Worker-31842-has-no-heartbeat-50-seconds-restarting-mean
says that "a blocking operation such as an infinite loop in your application can prevent this, and will force the affected worker to be restarted after a timeout."
Is it correct that if Mojo worker is executing some action with non-async Perl code which is taking longer than
heartbeat_timeout
to complete the worker will be eventually sent SIGQUIT, and, later on, killed with SIGKILL signal?And Mojo worker cannot send heartbeat to the master process until it finishes non-async action execution?
Beta Was this translation helpful? Give feedback.
All reactions