amp icon indicating copy to clipboard operation
amp copied to clipboard

Allow signal handling for Uv w/o 100% cpu usage

Open duckboy81 opened this issue 4 years ago • 9 comments

Ref #329

To be honest this could lend itself to its own Uv specific example file, but here's something that could work regardless of driver used.

Again, downside is that the end of code execution is not in the signal handling function, but sometime after the Loop::run() line.

duckboy81 avatar Oct 23 '20 20:10 duckboy81

Not a very good solution imo. Now the signal handler can't control the exit code.

enumag avatar Oct 23 '20 20:10 enumag

I can't reproduce 100% CPU usage, but I get a warning:

Press Ctrl+C to exit...
^CCaught SIGINT, exiting...
PHP Warning:  zend_signal: handler was replaced for signal (2) after startup in Unknown on line 0

kelunik avatar Oct 23 '20 20:10 kelunik

I can't reproduce 100% CPU usage, but I get a warning:

Press Ctrl+C to exit...
^CCaught SIGINT, exiting...
PHP Warning:  zend_signal: handler was replaced for signal (2) after startup in Unknown on line 0

Using uv as the driver? (I've currently got uv 0.2.4-3 if it matters)

duckboy81 avatar Oct 23 '20 20:10 duckboy81

Please try with the latest master of https://github.com/bwoebi/php-uv.

kelunik avatar Oct 23 '20 20:10 kelunik

Please try with the latest master of https://github.com/bwoebi/php-uv.

Alright, give me a hot minute to try it.

PS: Thanks for being so active, you guys are awesome.

duckboy81 avatar Oct 23 '20 20:10 duckboy81

Please try with the latest master of https://github.com/bwoebi/php-uv.

Alright, give me a hot minute to try it.

PS: Thanks for being so active, you guys are awesome.

No luck. Same result.

I'm not sure this is worth putting too much work into unless someone else runs into the same issue. They can reference this conversation.

duckboy81 avatar Oct 23 '20 21:10 duckboy81

Which PHP version do you use?

kelunik avatar Oct 23 '20 21:10 kelunik

Using the following:

PHP 7.4.2 (cli) (built: Jan 21 2020 11:35:20) ( NTS ) Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies

If I switch from uv to the native driver, no issues too.

duckboy81 avatar Oct 23 '20 21:10 duckboy81

Perhaps there's an issue in ext-uv when calling exit inside a watcher callback? Exit handling changed recently to throw an exception internally (not sure which PHP version this happened in).

trowski avatar Oct 24 '20 02:10 trowski