Scamp in an improvisational situation (livecoding)

Hi,
I’m looking for a tool to teach python to musicians. I love Scamp for its simplicity but I would like to use it in a context of improvising musical algorithms in real time, as in the practice of livecoding.

Live coding involves manipulating, redefining, or altering software while it’s running. This approach explores hot swapping, reloading, or re-compiling parts of a software stack without interruption.

It looks complicated in scamp. I have tried sending portions of code to run directly in the python interpreter. But the interpreter becomes unusable while running an infinite loop.
I tried with fork_unsynchronized() but I get the following error " WARNING:root:Ran out of threads in the master clock’s ThreadPool; small thread creation delays may result. You can increase the number of threads in the pool to avoid this."

Can you think of a solution?
Do you think it is possible to modify the scamp code for this kind of multi-threading?
Sending code to several different interpreters is possible but not very elegant, and audio is not very reliable.
Thanks a lot

I have to mention that I always get this error starting the interpreter.

/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 2 leaked semaphore objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d ’

I recorded a video. It’s a complete mess but It’s illustrative of what I’m trying to do

Hey! First of all, the video is private, so I can’t watch it. I’m sure it would be really helpful to see a video of what you’re trying to do, so hopefully you can make get public or at least unlisted.

Before seeing what you’re trying to do, my sense is that it’s probably possible, but that it falls under the category of “things that I wouldn’t provide a warranty for”. Since you’re mostly going to use it for teaching, I think it could work really well, though, so let’s see if we can figure it out!

Oh, sorry. It’s public now

Ok, will try to explain better my idea:
In a normal python program you program all the processes (all the voices, all the sequences, etc…) and then you run everything and listen to the result, without any interaction.

My intention is to create, in real time, improvising, a sequence, execute it and while it is running, program the next one, execure the 2ond (in a newr thread) while the first one is playing, modify the first one, replace it by the one that is playing (while the second one is still playing), etc…

an example of a standard livecoding session