Closed p-pavel closed 2 years ago
This seems to be a bug. It is easier to reproduce if you use Delayed[Pause[2]]
as expression and keep refreshing the browser.
What seems to be happening is that when a request is aborted (because the browser is closed in the middle of a kernel evaluation) the whole session is terminated and the kernel is restarted.
It will be addressed, for now I would suggest you to use multiple kernels. Thanks!
I believe it may be a bug in wolframclient
, not wolframwebengine
multiple kernels do not help much btw :( Specifying —poolsize 20
actually make things worse as multiple kernels keep restarting.
kernels will be restarting, but every request come to a new kernel, so user experience should be a little better because they should not experience the slowdown of aborted kernels (unless every single request is aborted).
kernels will be restarting, but every request come to a new kernel, so user experience should be a little better because they should not experience the slowdown of aborted kernels (unless every single request is aborted).
I see. I mean the whole server will be stuck.
Thank you for the quick reply and diagnostics!
Sorry I can't participate and come out with pull request — don't know enough of Python
@riccardodivirgilio I wonder what the correct behaviour could look in this case? I suppose cancel should be forwarded to the kernel somehow but wolfram client library does not seem to support anything like "preemptive" evaluation to, say, abort the computation, right?
Not sure what exactly is happening yet, because we still need to debug this issue. Kernels are single threaded, so every request needs to wait for the first available kernel. By doing a preliminary look the bug here seems to be that instead of aborting only the current evaluation we are aborting the the whole session and quitting the kernel.
Kernels are single threaded, so every request needs to wait for the first available kernel. By doing a preliminary look the bug here seems to be that instead of aborting only the current evaluation we are aborting the the whole session and quitting the kernel.
This was the question: is aborting the current evaluation only at all possible?
Are there any news on this?
This problem occurs with demo applications too if one even press the submit button in the form pages little frequently. Solving this bug gracefully will be great as web apps and API are inherently supposed to handle frequent requests.
Sorry for late reply on this thread, but I wanted to give an official response for this ticket. Unfortunately this bug is making the webserver not suitable for production, and we won't be able to fix it because in my opinion it would need a complete rewrite (in short we would need to move away from ZMQ based communication and use WSTP instead). For this reason, WolframEngineForPython will remain a development only server, and we will be updating the documentation to reflect that.
We strongly suggest to run a different Wolfram product on a production environment:
https://www.wolfram.com/server-deployment-options/
If you are able to find a workaround for this issue, please don't esitate to submit a pull request, I will be more than glad to review it.
Otherwise here are some suggestions you can try that could make this webserver more usable:
Thanks. Riccardo Di Virgilio Wolfram Research Inc
Thanks @riccardodivirgilio for the sincere reply.
This is what I was afraid of from the start of the thread.
Unfortunately I see no way to make this working using current ZMQ approach :( All possible solutions I can think of require going deeper into layers of abstraction and I'm not that sure that WSTP will do it reasonably well either :(
RIP
I've made some relatively long running
APIFunction
:This runs ok:
But if you press Ctrl/Cmd - R in browser (or use some performance testing tool like
ab
) there're state errors inwolframwebengine
which effectively bring the server to its knees: