Skip to content

Commit

Permalink
Merge pull request #18 from ThilakReddyy/develop
Browse files Browse the repository at this point in the history
Add:timeout
  • Loading branch information
ThilakReddyy committed Jun 15, 2023
2 parents efebdf4 + 04d8ff3 commit 12a4e96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions jntuhresults/Executables/jntuhresultscraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions jntuhresults/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 12a4e96

Please sign in to comment.