Title: Best way to use IPC between node and python? · Issue #30 · extrabacon/python-shell · GitHub
Open Graph Title: Best way to use IPC between node and python? · Issue #30 · extrabacon/python-shell
X Title: Best way to use IPC between node and python? · Issue #30 · extrabacon/python-shell
Description: Hi, I'm trying to send data to a python script that controls motors on my Raspberry Pi, but I'm confused about the recommended way of doing this. Up until now I was using something like: function runMotor (speed) { var shell = new Python...
Open Graph Description: Hi, I'm trying to send data to a python script that controls motors on my Raspberry Pi, but I'm confused about the recommended way of doing this. Up until now I was using something like: function r...
X Description: Hi, I'm trying to send data to a python script that controls motors on my Raspberry Pi, but I'm confused about the recommended way of doing this. Up until now I was using something like: fu...
Opengraph URL: https://github.com/extrabacon/python-shell/issues/30
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Best way to use IPC between node and python?","articleBody":"Hi,\n\nI'm trying to send data to a python script that controls motors on my Raspberry Pi, but I'm confused about the recommended way of doing this. Up until now I was using something like:\n\n```\nfunction runMotor (speed) {\n var shell = new PythonShell('./script.py');\n shell.send(speed);\n shell.end( function(err) {\n if (err) throw err;\n }\n );\n}\n```\n\nBut I was getting some latency between sending the command and the motor moving, which I think is because there's a heavy overhead with instantiating a new instance of PythonShell each time and importing the modules every time on the python side. \n\nI tried moving the shell creation outside of the function, and not calling shell.end() immediately, but then it blocks, I assume because it only starts reading the input once you call shell.end(). You also can't instantiate the shell and call send() and end() multiple times, so what is the proper way to do this?\n\nI saw you mention using `var shell = PythonShell.run('./script.py')` instead in this issue: https://github.com/extrabacon/python-shell/issues/16#issuecomment-147716516, but when I try that it complains \"Error: write after end\". \n\nIs there a way to keep the script 'open' so that I don't incur an overhead from calling the constructor over and over and re-importing the modules the python script needs over and over?\n","author":{"url":"https://github.com/philraj","@type":"Person","name":"philraj"},"datePublished":"2016-03-15T22:18:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/30/python-shell/issues/30"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:208dac64-a804-bca2-9e3b-be0faed1a749 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AFDC:1DFAA9:7C9F74D:A0E9286:6975CFBE |
| html-safe-nonce | 622c0108d020a997d82374affd6a415b3c2e7781bc0bee875057f6422a138264 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkRDOjFERkFBOTo3QzlGNzREOkEwRTkyODY6Njk3NUNGQkUiLCJ2aXNpdG9yX2lkIjoiMTkzMjY3OTYwOTMwODI3MDUyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9e453dedb7352bb846ff763b870d31047ee1c826b35d0de373f3eb186d317263 |
| hovercard-subject-tag | issue:141115269 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/extrabacon/python-shell/30/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1370ab6af208d00039996173be1f7bc09683648dd36d8fec0f4251e4be8b7e66/extrabacon/python-shell/issues/30 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1370ab6af208d00039996173be1f7bc09683648dd36d8fec0f4251e4be8b7e66/extrabacon/python-shell/issues/30 |
| og:image:alt | Hi, I'm trying to send data to a python script that controls motors on my Raspberry Pi, but I'm confused about the recommended way of doing this. Up until now I was using something like: function r... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | philraj |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f |
| turbo-cache-control | no-preview |
| go-import | github.com/extrabacon/python-shell git https://github.com/extrabacon/python-shell.git |
| octolytics-dimension-user_id | 1558613 |
| octolytics-dimension-user_login | extrabacon |
| octolytics-dimension-repository_id | 17671651 |
| octolytics-dimension-repository_nwo | extrabacon/python-shell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 17671651 |
| octolytics-dimension-repository_network_root_nwo | extrabacon/python-shell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 488b30e96dfd057fbbe44c6665ccbc030b729dde |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width