Skip to content Skip to sidebar Skip to footer

How To Check If My Bokeh Server Application Is Completely Loaded And Rendered?

I would like to integrate my Bokeh Server Application in Electron. So what I did is to run bokeh server using python-shell like this mainWindow = new BrowserWindow({ width: 100

Solution 1:

I have found a bunch of workarounds. I am still waiting for the final solution.

Workaround 1

So I had to add this setTimeout as a workaround. If I do not use this the page would be stuck forever.

setTimeout(function () {
    mainWindow.show();
    mainWindow.loadURL('http://localhost:5006');
}, 3000);

Workaround 2

It checks if the bokeh port is still closed. But the elements may be not loaded and completely loaded

var portscanner = require('portscanner')
var _checkServerStatus = setInterval(function() {
  portscanner.checkPortStatus(5006, '127.0.0.1', function(error, status) {
    if (status == 'open') {  // status = 'open' or 'close'
        clearInterval(_checkServerStatus);
        console.log('Server running');
        mainWindow.loadURL(bokehUrl); 
    }
  });
}, 100);  

Workaround 3

Finally I found another workaround to check if all the elements are completely rendered. The answer is in this question:

oldLog = console.log;
console.log = function (message) {
    if(message.localeCompare('Bokeh items were rendered successfully') == 0){
        window.top.postMessage('show-bokeh-iframe', '*')
        console.log = oldLog;
    }
    oldLog.apply(console, arguments);
};

Workaround 4

There is a GH issue where where the writer ask for calling a callback when bokeh is completely loaded and rendered. The user foobarbecue suggests to verify if the bokeh page is rendered with MutationObserver, but I have never used it.


Post a Comment for "How To Check If My Bokeh Server Application Is Completely Loaded And Rendered?"