You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function() {
let pyshell = new PythonShell('.myscript.py')
let content = ""
pyshell.on('message',function(message){
content = message
})
return content // content needs to be message instead due to async nature it returns empty string
}
If you are looking to add this feature , I will gladly help and I was looking to contribute and this is great opportunity for my first contribution I am familiar with node and related web technologies so can you guide me through what i need to know to implement synchronous option
To be honest I'm probably not going to get to this anytime soon. I'd be happy to review a PR if someone submits it. Or if someone wants to donate to charity I can use that as motivation to get around to implementing this.
I'm actively maintaining this package and have an open PR (#320) fixing the runString() temp-path bug. I'm also tracking maintenance work publicly at dusan-maintains/oss-maintenance-log — all PRs and SLA are logged automatically every 6 hours.
If you're hitting issues with synchronized execution, the underlying problem is often related to how temp files are handled. Happy to look into this further if you can share a minimal repro.
Activity
Almenon commentedon Jan 24, 2019
Look at the readme - you want the run command.
dhaval-lila commentedon Jan 25, 2019
I am guessing you meant
PythonShell.run()that one too is async function. It takes callback function.Almenon commentedon Jan 25, 2019
Oh yeah you're right, sorry. We don't have a synchronous option but that's a good idea
dhaval-lila commentedon Jan 25, 2019
If you are looking to add this feature , I will gladly help and I was looking to contribute and this is great opportunity for my first contribution I am familiar with node and related web technologies so can you guide me through what i need to know to implement synchronous option
Almenon commentedon Jan 25, 2019
Thanks! For sychronus operation first we need to migrate to using promises (read #77). I've created a v2 branch for this: https://github.com/extrabacon/python-shell/tree/version2
Once we are using promises then we can make sync versions of our functions - see this article: https://medium.com/@patarkf/synchronize-your-asynchronous-code-using-javascripts-async-await-5f3fa5b1366d
WingDust commentedon Jan 10, 2020
I want to ask don't it already come true
abrichr commentedon Feb 4, 2020
+1
Almenon commentedon Feb 4, 2020
re-posting my comment from #77:
nkhil commentedon Feb 21, 2020
We had the same issue today, and ended up promisifying it like so:
karanbalani commentedon May 1, 2021
@nkhil this works (at least for now), thanks. :)
AlexString commentedon Apr 2, 2022
@nkhil implementation worked for me but I did something more like this in a
Class:dschweinbenz commentedon Jan 10, 2023
One should use
return reject(err)to avoid resolving the request afterwards. See https://stackoverflow.com/questions/32536049/do-i-need-to-return-after-early-resolve-rejectdusan-maintains commentedon Mar 10, 2026
I'm actively maintaining this package and have an open PR (#320) fixing the
runString()temp-path bug. I'm also tracking maintenance work publicly at dusan-maintains/oss-maintenance-log — all PRs and SLA are logged automatically every 6 hours.If you're hitting issues with synchronized execution, the underlying problem is often related to how temp files are handled. Happy to look into this further if you can share a minimal repro.