C2-151 commited on
Commit
cf96efa
·
1 Parent(s): 00b6c5e

Fix websocket disconnect by lazily initializing current_sim when None

Browse files
Files changed (1) hide show
  1. frontend/interactive_server.py +15 -0
frontend/interactive_server.py CHANGED
@@ -562,6 +562,21 @@ async def websocket_endpoint(websocket: WebSocket):
562
  def init_sim():
563
  global current_sim
564
  with pybullet_lock:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
  is_connected = False
566
  if current_sim is not None and current_sim.client is not None:
567
  try:
 
562
  def init_sim():
563
  global current_sim
564
  with pybullet_lock:
565
+ if current_sim is None:
566
+ print("Initializing PandaApp lazily in websocket_endpoint...", flush=True)
567
+ env_path = os.path.join(PROJECT_SRC, "envs", "env1.json")
568
+ try:
569
+ current_sim = PandaApp(
570
+ env_json_path=env_path,
571
+ gui=False,
572
+ seed=0,
573
+ agent=None,
574
+ viz=False
575
+ )
576
+ except Exception as e:
577
+ print(f"Failed to initialize lazy PandaApp: {e}", flush=True)
578
+ raise e
579
+
580
  is_connected = False
581
  if current_sim is not None and current_sim.client is not None:
582
  try: