How to abort a long running command in wx.py.PyShell ? like pressing Ctrl+c
in console.
Do you mean, as a human being? Ctrl-C should work in PyShell just like
it does in the console.
Unfortunately PyShell doesn't have KeyboardInterrupt support. Since the Python shell is running in the same process it is the GUI that receives the key events, so they are not turned into a SIGINT by the system. Also since they are running in the same process without threading, PyShell doesn't get the event until after the long running python code completes.
There are a couple ways to work around this that come to mind, but so far nobody has attempted it as far as I know. I will gladly review and apply patches that implement this if anyone wants to give it a try.
Actually I have built an application over PyShell and it would be very costly for me look for me to look for other alternatives…
Thanks and Regards
Hemadri
···
On Sat, Mar 14, 2015 at 3:04 AM, Robin Dunn robin@alldunn.com wrote:
linuxNewBee wrote:
How to abort a long running command in wx.py.PyShell ? like pressing Ctrl+c
in console.
Do you mean, as a human being? Ctrl-C should work in PyShell just like
it does in the console.
Tim Roberts wrote:
Unfortunately PyShell doesn’t have KeyboardInterrupt support. Since the Python shell is running in the same process it is the GUI that receives the key events, so they are not turned into a SIGINT by the system. Also since they are running in the same process without threading, PyShell doesn’t get the event until after the long running python code completes.
There are a couple ways to work around this that come to mind, but so far nobody has attempted it as far as I know. I will gladly review and apply patches that implement this if anyone wants to give it a try.
Actually I have built an application over PyShell and it would be very
costly for me look for me to look for other alternatives...
Probably the best fix would be to run the code executed in the PyShell in another Python process, using a small local server in the process to communicate the code snippets to be executed, send back the stdout, stderr, exceptions, etc. for display in PyShell. Then long running code snippets do not block the PyShell GUI and supporting things like interrupting the execution of the code can be just another message that gets sent over to the other process and handled there.
I have tried that as follows…facing issue…Do u have any suggestion
Create a new Python Process…
started thread which take output steam and read the ouput and put it in a queue
other thread which read the queue and update the GUI. using wx.CallAfter()
but the issue when that process generates lots of output…that is is too many call to wx.CallAfter() the GUI goes in responsive…
···
On Tue, Mar 17, 2015 at 7:05 PM, Robin Dunn robin@alldunn.com wrote:
Hello,
what are work around ?
Actually I have built an application over PyShell and it would be very
costly for me look for me to look for other alternatives…
Hemadri Saxena wrote:
Probably the best fix would be to run the code executed in the PyShell in another Python process, using a small local server in the process to communicate the code snippets to be executed, send back the stdout, stderr, exceptions, etc. for display in PyShell. Then long running code snippets do not block the PyShell GUI and supporting things like interrupting the execution of the code can be just another message that gets sent over to the other process and handled there.