MessageLoop() swallows/ignores SIGTERM

86 views
Skip to first unread message

reto.ind...@gmail.com

unread,
Oct 8, 2017, 4:40:02 AM10/8/17
to CEF Python
Hello

I try to save screenshots consecutively in off-screen-rendering mode. For this I took the screenshot.py example as a starting point and modified the code to save each OnPaint buffer and added a signal interceptor the catch SIGINT and SIGTERM to close the browser and quit the message loop. You can find the example here: https://gist.github.com/indr/aa269f33968ee8fa0ce60f9c8864776f

I've found that my interceptor only works when a call back from CEF Python is fired. Once there is no call back, the signals are not caught, or my handler is not called. I suspect it has something to do with MessageLoop().

CEF Python 57.0
Python 2.7.13 64bit

Any tips or hints?

Czarek Tomczak

unread,
Oct 8, 2017, 5:59:42 AM10/8/17
to CEF Python
Please provide a patch file with your changes to the screenshot.py example.

reto.ind...@gmail.com

unread,
Oct 8, 2017, 6:30:26 AM10/8/17
to CEF Python
I don't know how to attach files here. I pasted the patch here: https://pastebin.com/cj9270Pw

Thank you for looking into this!

Czarek Tomczak

unread,
Oct 8, 2017, 7:42:35 AM10/8/17
to CEF Python

Czarek Tomczak

unread,
Oct 8, 2017, 7:45:37 AM10/8/17
to CEF Python
Try also running app with "--debug" command line flag passed and attach logs displayed in console (not from log file).

reto.ind...@gmail.com

unread,
Oct 9, 2017, 12:52:40 AM10/9/17
to CEF Python
$ python screenshot.py --debug
[screenshot.py] CEF Python 57.0
[screenshot.py] Python 2.7.13 64bit
[screenshot.py] Pillow 3.2.0
[1009/064951.797459:INFO:cef_log.cpp(8)] [Browser process] Initialize() called

[1009/064951.797711:INFO:cef_log.cpp(8)] [Browser process] CefInitialize()

[1009/064951.797868:INFO:cef_log.cpp(8)] [Browser process] App_OnBeforeCommandLineProcessing_BrowserProcess()

[1009/064951.797887:INFO:cefpython_app.cpp(83)] [Browser process] Command line string for the browser process: --browser-subprocess-path=/usr/lib/python2.7/site-packages/cefpython3/subprocess --no-sandbox --lang=en-US --log-file=/home/reto/Projects/cefpython/examples/debug.log --log-severity=info --resources-dir-path=/usr/lib/python2.7/site-packages/cefpython3 --locales-dir-path=/usr/lib/python2.7/site-packages/cefpython3/locales --remote-debugging-port=54725

[1009/064951.799505:INFO:cefpython_app.cpp(132)] [Browser process] OnBeforeChildProcessLaunch() command line: /usr/lib/python2.7/site-packages/cefpython3/subprocess --type=zygote --no-sandbox --lang=en-US --locales-dir-path=/usr/lib/python2.7/site-packages/cefpython3/locales --log-file=/home/reto/Projects/cefpython/examples/debug.log --log-severity=info --resources-dir-path=/usr/lib/python2.7/site-packages/cefpython3

[1009/064951.828545:INFO:cefpython_app.cpp(132)] [Browser process] OnBeforeChildProcessLaunch() command line: /usr/lib/python2.7/site-packages/cefpython3/subprocess --type=gpu-process --no-sandbox --lang=en-US --locales-dir-path=/usr/lib/python2.7/site-packages/cefpython3/locales --log-file=/home/reto/Projects/cefpython/examples/debug.log --log-severity=info --resources-dir-path=/usr/lib/python2.7/site-packages/cefpython3

[1009/064951.828664:INFO:cefpython_app.cpp(132)] [Browser process] OnBeforeChildProcessLaunch() command line: /usr/lib/python2.7/site-packages/cefpython3/subprocess --type=gpu-process --no-sandbox --lang=en-US --locales-dir-path=/usr/lib/python2.7/site-packages/cefpython3/locales --log-file=/home/reto/Projects/cefpython/examples/debug.log --log-severity=info --resources-dir-path=/usr/lib/python2.7/site-packages/cefpython3 --supports-dual-gpus=false --gpu-driver-bug-workarounds=7,23,74 --disable-gl-extensions=GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent --gpu-vendor-id=0x10de --gpu-device-id=0x1349 --gpu-driver-vendor --gpu-driver-version --gpu-driver-date --gpu-secondary-vendor-ids=0x8086 --gpu-secondary-device-ids=0x1916 --lang=en-US --locales-dir-path=/usr/lib/python2.7/site-packages/cefpython3/locales --log-file=/home/reto/Projects/cefpython/examples/debug.log --log-severity=info --resources-dir-path=/usr/lib/python2.7/site-packages/cefpython3

[screenshot.py] Viewport size: (1024, 5000)
[screenshot.py] Loading url: https://github.com/cztomczak/cefpython
[1009/064951.840425:INFO:cef_log.cpp(8)] [Browser process] CreateBrowserSync() called

[1009/064951.842026:INFO:cef_log.cpp(8)] [Browser process] navigateUrl: https://github.com/cztomczak/cefpython

[1009/064951.842175:INFO:cef_log.cpp(8)] [Browser process] CefBrowser::CreateBrowserSync()

[1009/064951.854552:INFO:cef_log.cpp(8)] [Browser process] GetPyBrowser(): create new PyBrowser, browserId=1

[1009/064951.855370:INFO:cefpython_app.cpp(132)] [Browser process] OnBeforeChildProcessLaunch() command line: /usr/lib/python2.7/site-packages/cefpython3/subprocess --type=renderer --no-sandbox --disable-databases --primordial-pipe-token=7254B7B5C3749B8E1DBF1549FDB8E93E --lang=en-US --lang=en-US --locales-dir-path=/usr/lib/python2.7/site-packages/cefpython3/locales --log-file=/home/reto/Projects/cefpython/examples/debug.log --log-severity=info --resources-dir-path=/usr/lib/python2.7/site-packages/cefpython3

[1009/064951.866313:INFO:cef_log.cpp(8)] [Browser process] CefBrowser::CreateBrowserSync() succeeded

[1009/064951.866356:INFO:cef_log.cpp(8)] [Browser process] CefBrowser window handle = 0

[1009/064951.866904:INFO:cef_log.cpp(8)] [Browser process] MessageLoop()

[1009/064951.975580:ERROR:child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain
[screenshot.py] Saved image: /home/reto/Projects/cefpython/examples/screenshot-0.png
[1009/064953.034334:INFO:cefpython_app.cpp(207)] [Renderer process] OnContextCreated()

[1009/064953.034766:INFO:client_handler.cpp(39)] [Browser process] OnProcessMessageReceived(): OnContextCreated

[1009/064953.034813:INFO:cef_log.cpp(8)] [Browser process] V8ContextHandler_OnContextCreated()

[screenshot.py] Saved image: /home/reto/Projects/cefpython/examples/screenshot-1.png
[screenshot.py] Saved image: /home/reto/Projects/cefpython/examples/screenshot-2.png

[screenshot.py] Web page loading is complete
Killed

Message has been deleted

reto.ind...@gmail.com

unread,
Oct 9, 2017, 1:01:44 AM10/9/17
to CEF Python

This is actually what I tried in the first place. I figured that my handler was never called, even though str(signal.getsignal(signum.SIGINT)) returns a reference to my registered handler (exit_gracefully). When I put the registrations before the browser creation, I can use Ctrl+C to abort the script, but neither does the script continue with the next line after cef.MessageLoop() nor is my handler called.

Czarek Tomczak

unread,
Oct 9, 2017, 1:44:56 AM10/9/17
to CEF Python

reto.ind...@gmail.com

unread,
Oct 9, 2017, 1:53:37 AM10/9/17
to CEF Python
Thank you very much for your time and support!
Reply all
Reply to author
Forward
0 new messages