diff --git a/jntuhresults/Executables/jntuhresultscraper.py b/jntuhresults/Executables/jntuhresultscraper.py index 97b4499d..e99138f2 100644 --- a/jntuhresults/Executables/jntuhresultscraper.py +++ b/jntuhresults/Executables/jntuhresultscraper.py @@ -204,5 +204,8 @@ async def scrape_all_results(self, exam_code="all"): def run(self): - return asyncio.run(self.scrape_all_results()) - + timeout = 3.5 # Timeout value in seconds + try: + return asyncio.run(asyncio.wait_for(self.scrape_all_results(), timeout)) + except asyncio.TimeoutError: + return None \ No newline at end of file diff --git a/jntuhresults/views.py b/jntuhresults/views.py index 6ab2b9b5..5fb280dd 100644 --- a/jntuhresults/views.py +++ b/jntuhresults/views.py @@ -91,6 +91,7 @@ def get(self,request): except Exception as e: print(htno,e) + del jntuhresult # Catch any exceptions raised during scraping return HttpResponse(htno+" - 500 Internal Server Error")