pyth icon indicating copy to clipboard operation
pyth copied to clipboard

Add debug code to output before code is run (online compiler)

Open willsherwood opened this issue 9 years ago • 6 comments

while debugging code, it is useful to have the python code printed to the output before the program runs. If the program hangs, it's very hard to debug because the code is never shown.

willsherwood avatar May 10 '15 20:05 willsherwood

I'll guess you mean the Online Compiler, since offline compiler already does this. Not sure, if this is easy to implement.

Maybe the online compiler could simple terminate after running for 5 seconds and return the result, as far as it is computed. This would also prevent the server from crashing.

jakobkogler avatar May 10 '15 20:05 jakobkogler

Yes, this is only an issue for people using the pyth online compiler for example on their phones

willsherwood avatar May 10 '15 21:05 willsherwood

There is a very easy linux-only way to do the timeout using the signal module in the standard library. I don't think threads can be avoided if it has to be multiplataform.

gcq avatar May 11 '15 01:05 gcq

One way to implement this without threads is with a command line flag to set the timeout, that would be enabled in the online versions.

isaacg1 avatar May 15 '15 08:05 isaacg1

When testing programs that seem to hang one can now (since 99838ee14d2b64692edac60c5952bcfabcffc0e0) add .q to the start of the program. I would like to see a timeout function, though.

PurkkaKoodari avatar Dec 28 '15 11:12 PurkkaKoodari

A fix for this, that covers much more, is to use web sockets to do real time communication from the server to the client. However, this is very involved.

Maltysen avatar Dec 29 '15 05:12 Maltysen