{"action":"closed","issue":{"url":"https://api.github.com/repos/bokeh/bokeh/issues/3567","repository_url":"https://api.github.com/repos/bokeh/bokeh","labels_url":"https://api.github.com/repos/bokeh/bokeh/issues/3567/labels{/name}","comments_url":"https://api.github.com/repos/bokeh/bokeh/issues/3567/comments","events_url":"https://api.github.com/repos/bokeh/bokeh/issues/3567/events","html_url":"https://github.com/bokeh/bokeh/issues/3567","id":125410720,"number":3567,"title":"Starting bokeh serve in subprocess","user":{"login":"ChristianTremblay","id":6376327,"avatar_url":"https://avatars.githubusercontent.com/u/6376327?v=3","gravatar_id":"","url":"https://api.github.com/users/ChristianTremblay","html_url":"https://github.com/ChristianTremblay","followers_url":"https://api.github.com/users/ChristianTremblay/followers","following_url":"https://api.github.com/users/ChristianTremblay/following{/other_user}","gists_url":"https://api.github.com/users/ChristianTremblay/gists{/gist_id}","starred_url":"https://api.github.com/users/ChristianTremblay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChristianTremblay/subscriptions","organizations_url":"https://api.github.com/users/ChristianTremblay/orgs","repos_url":"https://api.github.com/users/ChristianTremblay/repos","events_url":"https://api.github.com/users/ChristianTremblay/events{/privacy}","received_events_url":"https://api.github.com/users/ChristianTremblay/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bokeh/bokeh/labels/type:%20feature","name":"type: feature","color":"53777A"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/bokeh/bokeh/milestones/11","html_url":"https://github.com/bokeh/bokeh/milestones/short-term","labels_url":"https://api.github.com/repos/bokeh/bokeh/milestones/11/labels","id":811343,"number":11,"title":"short-term","description":"Collects issues that need to be resolved soon, but not before the next release.\r\nThis milestone is always open and it gets populated from the either the long-term milestone or from new (unmilestoned) issues.\r\n\r\nRef: https://github.com/ContinuumIO/bokeh/wiki/BEP-1:-Issues-and-PRs-management#issue-times","creator":{"login":"damianavila","id":1640669,"avatar_url":"https://avatars.githubusercontent.com/u/1640669?v=3","gravatar_id":"","url":"https://api.github.com/users/damianavila","html_url":"https://github.com/damianavila","followers_url":"https://api.github.com/users/damianavila/followers","following_url":"https://api.github.com/users/damianavila/following{/other_user}","gists_url":"https://api.github.com/users/damianavila/gists{/gist_id}","starred_url":"https://api.github.com/users/damianavila/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damianavila/subscriptions","organizations_url":"https://api.github.com/users/damianavila/orgs","repos_url":"https://api.github.com/users/damianavila/repos","events_url":"https://api.github.com/users/damianavila/events{/privacy}","received_events_url":"https://api.github.com/users/damianavila/received_events","type":"User","site_admin":false},"open_issues":386,"closed_issues":44,"state":"open","created_at":"2014-10-02T12:30:03Z","updated_at":"2016-09-07T04:33:59Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2016-01-07T15:04:35Z","updated_at":"2016-09-07T04:33:59Z","closed_at":"2016-09-07T04:33:59Z","body":"As bokeh serve is a tornado process that needs to run in the main thread, if a script needs to start the server, it cannot use a thread... and I'm not sure we could use a coroutine to start the serve inside another program.\r\n\r\nFor discussion, I tried importing the bootstrap... or the server ... and I always get stuck with the tornado IOLoop already running. \r\n\r\nSubprocess seems the way to go.\r\n\r\nWhat would be the better way to start the process, keep track of it in case of a failure so it can be killed and restart.\r\n\r\nI came out with this first attempt which start the server : \r\n```\r\n    def startServer(self):\r\n        if 'win' in sys.platform:\r\n            commandToExecute = \"bokeh.bat serve\"\r\n        else:\r\n            commandToExecute = \"bokeh serve\"\r\n        cmdargs = shlex.split(commandToExecute)\r\n        #showDebug(\"EXECUTE BOKEH SERVE COMMAND '%s'\" % cmdargs)\r\n        p = subprocess.Popen(cmdargs, stdout=PIPE, stderr=PIPE)\r\n        output, errors = p.communicate()\r\n        if p.returncode:\r\n            print('Failed running %s' % commandToExecute)\r\n            raise Exception(errors)\r\n        return output.decode('utf-8')\r\n```\r\n\r\nThis is good until I restart the python kernel... the process continues to run as it is not \"linked\" to the app.\r\n\r\nI keep in mind that in fact, I start a different python interpreter that runs the bokeh-script.py. It's then hard to retrive which python process is running the script (at least in Windows).\r\n\r\nIt would be possible to write the pid.id somewhere in a file at startup and retrieve it when needed... doesn't seem like a full elegant way though.\r\n\r\nWould it be possible to consider a \"standard\" way in Bokeh to do that (an official bokeh function ?) \r\n\r\nThe idea behind that is to be able to have a simple app to run by the user. Bokeh serve would be started in the background and the user don't have to bother.\r\n\r\nIdeas welcome"}}
{"actor":{"display_login":"bryevdv"}}