Abhishek Thakur commited on
Commit
eac46fd
·
1 Parent(s): d27e581

thread deamon

Browse files
Files changed (1) hide show
  1. competitions/app.py +17 -5
competitions/app.py CHANGED
@@ -68,8 +68,14 @@ def run_job_runner():
68
  job_runner.run()
69
 
70
 
71
- thread = threading.Thread(target=run_job_runner)
72
- thread.start()
 
 
 
 
 
 
73
 
74
 
75
  app = FastAPI()
@@ -197,10 +203,16 @@ async def fetch_leaderboard(
197
 
198
  @app.post("/my_submissions", response_class=JSONResponse)
199
  async def my_submissions(request: Request, user_token: str = Depends(utils.user_authentication)):
200
- if user_token is None:
201
- user_token = "abc"
202
-
203
  competition_info = CompetitionInfo(competition_id=COMPETITION_ID, autotrain_token=HF_TOKEN)
 
 
 
 
 
 
 
 
 
204
  sub = Submissions(
205
  end_date=competition_info.end_date,
206
  submission_limit=competition_info.submission_limit,
 
68
  job_runner.run()
69
 
70
 
71
+ def start_job_runner_thread():
72
+ thread = threading.Thread(target=run_job_runner)
73
+ thread.daemon = True
74
+ thread.start()
75
+ return thread
76
+
77
+
78
+ _ = start_job_runner_thread()
79
 
80
 
81
  app = FastAPI()
 
203
 
204
  @app.post("/my_submissions", response_class=JSONResponse)
205
  async def my_submissions(request: Request, user_token: str = Depends(utils.user_authentication)):
 
 
 
206
  competition_info = CompetitionInfo(competition_id=COMPETITION_ID, autotrain_token=HF_TOKEN)
207
+ if user_token is None:
208
+ return {
209
+ "response": {
210
+ "submissions": "",
211
+ "submission_text": SUBMISSION_TEXT.format(competition_info.submission_limit),
212
+ "error": "**Invalid token. Please login.**",
213
+ "team_name": "",
214
+ }
215
+ }
216
  sub = Submissions(
217
  end_date=competition_info.end_date,
218
  submission_limit=competition_info.submission_limit,