switham / pyinthephone

A Python notebook for Android devices
Other
3 stars 1 forks source link

In notebook, stream output, allow interrupt. #4

Open switham opened 11 years ago

switham commented 11 years ago

When a user-python process in the notebook takes a while,

This requires processes or threads on the server. (At least one user-python thread, plus the server itself.) Also requires Ajax (xml-http-request) stuff. I don't even know whether wsgiref.simple_server supports requests in parallel. Not that that's absolutely necessary: the server can return from running a Python block quickly after having launched a separate thread or process to do the actual work.

Anything I do requires some non-trivial (to me) javascript to periodically poll the server for more output. I am imagining polling once a second, not very low latency.

I don't know whether I want to import a complete pseudo-sockets library. It's good not to reinvent the (two-sided Python/Javascript) wheel, but it would have to be pure python on the server, and I want it not too bulky. Assuming multiple open notebooks, what I need here does require streams open in parallel, but only coming from server to client.

When one python block's code is still running, the notebook shouldn't let you start another running.

The idea that you might have multiple notebooks open at once is [https://github.com/switham/pyinthephone/issues/09].

switham commented 11 years ago

The Most Crappy Minimum-Change Way

The way the code currently works is

So, here is what seems to me a minimum modification. The idea that the web server should always return fast, and the idea of putting the user output in actual files, come from David Baumgold @singingwolfboy .

img_20130702_005345