{"action":"opened","issue":{"url":"https://api.github.com/repos/extrabacon/python-shell/issues/18","labels_url":"https://api.github.com/repos/extrabacon/python-shell/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/extrabacon/python-shell/issues/18/comments","events_url":"https://api.github.com/repos/extrabacon/python-shell/issues/18/events","html_url":"https://github.com/extrabacon/python-shell/issues/18","id":114044572,"number":18,"title":"python-shell 'send' issue","user":{"login":"punit-dato","id":12615310,"avatar_url":"https://avatars.githubusercontent.com/u/12615310?v=3","gravatar_id":"","url":"https://api.github.com/users/punit-dato","html_url":"https://github.com/punit-dato","followers_url":"https://api.github.com/users/punit-dato/followers","following_url":"https://api.github.com/users/punit-dato/following{/other_user}","gists_url":"https://api.github.com/users/punit-dato/gists{/gist_id}","starred_url":"https://api.github.com/users/punit-dato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/punit-dato/subscriptions","organizations_url":"https://api.github.com/users/punit-dato/orgs","repos_url":"https://api.github.com/users/punit-dato/repos","events_url":"https://api.github.com/users/punit-dato/events{/privacy}","received_events_url":"https://api.github.com/users/punit-dato/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-29T13:00:42Z","updated_at":"2015-10-29T13:00:42Z","closed_at":null,"body":"Hey - I'm trying to the send/message functionality on python-shell to exchange data between a long-running python script and node, but I'm seeing that the messages don't get handled till I end the input stream.  For example, the following sample code does not invoke the 'message' callback (or 'close' or 'error):\r\n\r\n```javascript\r\nvar pyshell = new PythonShell('python/helloworld.py', options);\r\n\r\npyshell.send({'hello': 'world'});\r\n\r\npyshell.on('message', function(message) {\r\n  console.log(\"message - \", message);\r\n}).on('close', function (result) {\r\n  console.log(\"close - \", result);\r\n}).on('error', function (err) {\r\n  console.log(\"error\")\r\n});\r\n```\r\n\r\nThe python is the same as your echo script. \r\n```python\r\nimport sys, json\r\n\r\n# simple JSON echo script\r\nfor line in sys.stdin:\r\n  print json.dumps(json.loads(line))\r\n```\r\n\r\nNow, if I close the connection after the above code, then I get all the messages:\r\n```javascript\r\npyshell.end(function (err) {\r\n  if (err) throw err;\r\n  console.log('finished');\r\n});\r\n```\r\n\r\nThis won't work for me as my python script maintains state and I don't want to re-run the script every time. I'd rather have a long running child process I could pass messages back and forth from.  This seems like a bug. Any suggestions?"}}