I am making an online judge I am using the IDEONE API to compile the file. So when my user uploads a file, there is a function that takes the file and compiles the file using the IDElone API. But the problem is that the file is being compiled, if my user clicks on a new link, then there is no way to ensure that the compilation is half-ended whether the user fully executes the function before the redirect?
My first thought was to create a thread and compile the thread. And when the thread is running, I can show a new view to the user. But apparently you can not run a thread in PHP, so I'm out of ideas. Thank you. In PHP, there really is no way to ensure that the user stays on the page, while something is complete.
Your best bet passes your compilation job into the background process. One way to do this is to insert a line in the database with the information you want to process. You can show them to the user immediately that the message stated in their job is queued, and will be processed soon. Then set up one to get information from the database, and request your API. When this is done, you update the database again to do this work. If this is a particularly long-lasting process, you can email the user that his job has been completed so that he does not have to sit and wait.
Overall, your goal gives good feedback about what is happening to the user, your process is being run in such a way that the user can be navigated and lost.
No comments:
Post a Comment