Set a timeout for a python script

邓 君卓

I am now trying to run python codes from user input in a .netcore project on Linux(Debian). However, something like a dead loop may use up too much resource. I wonder if I can abort  oprations that cost too much time.


Maybe to set a timeout, so something like

while True:


won't block everything


This is my code at present:


py = Python.CreateEngine();

scope = py.CreateScope();



I want to set a timeout or kill a script when it is running for too long. (Maybe I could use a timer and kill the script when it runs for too long as a workaround.)

Join to automatically receive all group messages.