### hugox14's blog

By hugox14, history, 4 days ago, ,

Hi, I'm currently working on a project using PHP to develop a judge where my colleagues can send solutions to exercises that are typically from a basic programming course. All solutions must be written in python.

The code is executed in exec() and then the user's output is stored in a .txt file. Later the system reads that file and compares it with a .txt file that has the correct outputs.

The problem is that I can not know when TLE occurs. When a user sends a python file with an infinite buble for example, the web page hangs.

If you have some tip or similar experience I would appreciate it very much.

•
• +5
•

 » 4 days ago, # |   0 I've been searching for things about OJs for days and it's not only about time...You should search more about many things like.. resource limit disabling network disabling sys calls load balancing disabling threading... etc...
 » 4 days ago, # |   -11 You can take a good method for every user that when a user send his/her code then it make a txt file and your compiler just check this and clean that code and then other do. and in this method you have to do write queue function (you can use ajax for do this )if you don't do that then you fetch many problems when the user database are huge.Or you can use one user one code compiler main file then your judge can handle huge user activity. Thank You.
 » 4 days ago, # |   0 I found open source OJLink of Website : The online Judge
 » 4 days ago, # |   +3 Hi hugox14!As EbraM96 said, if you are planning to create a robust OJ you should take into account security. Basically you should run the submissions on a sandbox environment to avoid problems.Anyway, an easy way to limit execution time is with the "timeout" command.
•  » » 4 days ago, # ^ |   0 Wow the timeout command has helped me. I am using it in the following way: exec("timeout 1 python example.py < in.txt > out.txt") and now the process stops, although not after a second, I think that around 5 seconds. I will investigate that. Many thanks!