Dear Friends, Hi!
Is there a way to interrupt execution of python script in brython and then resume it from that state?
The matter is I'm trying to come up with some simple game-like functionality to teach basics of python. The idea is to display game field with some character on it and ask user to control this character with simple python code like this:
forward()
turnLeft()
for i in range(3):forward()
pickObject()
The problem is that actions like "forward" and "turnLeft" should take some time (and probably be animated). And I do not want browser to freeze during the execution.I suppose that if I find a way to interrupt the program (e.g. on "forward") call, then play required animation outside of the user's code, and then resume the execution - I will achieve the goal.
I also think such "interruption" could be used for simulating blocking operations so I suspect it exists in some form but I fail to find it.
I read about debugging (and auto inserting trace between lines, but as I understand it works only in record mode?) Though perhaps I can fall down to recording the execution and replaying it for user...
On Monday, 4 July 2016 18:10:21 UTC-3, Rodion Gorkovenko wrote:Dear Friends, Hi!
Is there a way to interrupt execution of python script in brython and then resume it from that state?
The matter is I'm trying to come up with some simple game-like functionality to teach basics of python. The idea is to display game field with some character on it and ask user to control this character with simple python code like this:
forward()
turnLeft()
for i in range(3):forward()
pickObject()Perhaps, instead of re-inventing the wheel, you could either use Reeborg's World as-is (http://reeborg.ca/reeborg.html - tutorial/documentation at http://reeborg.ca/docs/en/) or build from its (slightly messy) code. Reeborg's World uses Brython.
> Is there a way to interrupt execution of python script in brython and then
> resume it from that state?
>
I'm assuming you are asking for a javascript API to do so. If this is
the case, at this moment this is not possible . Brython core is
synchronous .