Libra-1995 commited on
Commit
0676e8e
·
1 Parent(s): 72af80c

feat: fix bug

Browse files
Files changed (1) hide show
  1. web_server.py +17 -1
web_server.py CHANGED
@@ -294,6 +294,17 @@ class EnvHandlerManager:
294
  os.makedirs(output, exist_ok=True)
295
  return EnvHandler(cfg, output)
296
 
 
 
 
 
 
 
 
 
 
 
 
297
  def get_env_handler(self, env_id: str) -> EnvHandler:
298
  """
299
  Get the environment handler for the given environment ID.
@@ -338,7 +349,12 @@ def _get_env_handler(
338
  token_info = get_token_info(token)
339
  except Exception:
340
  raise HTTPException(status_code=401)
341
- env_handler = env_manager.get_env_handler(token_info["submission_id"])
 
 
 
 
 
342
  if env_handler is None:
343
  raise HTTPException(status_code=404, detail="Environment handler already closed.")
344
  return env_handler
 
294
  os.makedirs(output, exist_ok=True)
295
  return EnvHandler(cfg, output)
296
 
297
+ def exists_env_handler(self, env_id: str) -> bool:
298
+ """
299
+ Check if the environment handler for the given environment ID exists.
300
+ Args:
301
+ env_id (str): The environment ID.
302
+ Returns:
303
+ bool: True if the environment handler exists, False otherwise.
304
+ """
305
+ with self._lock:
306
+ return env_id in self._env_handlers
307
+
308
  def get_env_handler(self, env_id: str) -> EnvHandler:
309
  """
310
  Get the environment handler for the given environment ID.
 
349
  token_info = get_token_info(token)
350
  except Exception:
351
  raise HTTPException(status_code=401)
352
+
353
+ submission_id = token_info["submission_id"]
354
+ if not env_manager.exists_env_handler(submission_id):
355
+ update_submission_status(token_info["team_id"], submission_id, SubmissionStatus.PROCESSING.value)
356
+
357
+ env_handler = env_manager.get_env_handler(submission_id)
358
  if env_handler is None:
359
  raise HTTPException(status_code=404, detail="Environment handler already closed.")
360
  return env_handler