re-type commited on
Commit
3b5c762
·
verified ·
1 Parent(s): 4ce6bb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -758,8 +758,6 @@ def create_gradio_interface():
758
 
759
  # --- Application Startup ---
760
  def run_application():
761
- e = None # Predefine e to avoid free variable error
762
- fallback_error = None # Predefine fallback_error for clarity
763
  gradio_app = None # Predefine gradio_app for cleanup
764
  try:
765
  gradio_app = create_gradio_interface()
@@ -776,11 +774,12 @@ def run_application():
776
  )
777
  except Exception as e:
778
  logger.error(f"Application startup failed: {e}", exc_info=True)
 
779
  try:
780
  logger.info("🔄 Falling back to Gradio-only mode...")
781
- gradio_app = create_gradio_interface()
782
  logger.warning("⚠️ Running without request queuing in fallback mode.")
783
- gradio_app.launch(
784
  server_name="0.0.0.0",
785
  server_port=7860,
786
  share=False,
@@ -790,18 +789,17 @@ def run_application():
790
  logger.error(f"Fallback failed: {fallback_error}", exc_info=True)
791
  print("❌ Application failed to start. Check logs for details.")
792
  finally:
793
- if gradio_app:
794
  try:
795
- gradio_app.close()
796
  except Exception as close_error:
797
- logger.warning(f"Failed to close Gradio app in fallback: {close_error}")
798
  finally:
799
  if gradio_app:
800
  try:
801
  gradio_app.close()
802
  except Exception as close_error:
803
- logger.warning(f"Failed to close Gradio app: {close_error}")
804
-
805
  # --- Main Entry Point ---
806
  if __name__ == "__main__":
807
  print("🧬 Gene Analysis Pipeline Starting...")
 
758
 
759
  # --- Application Startup ---
760
  def run_application():
 
 
761
  gradio_app = None # Predefine gradio_app for cleanup
762
  try:
763
  gradio_app = create_gradio_interface()
 
774
  )
775
  except Exception as e:
776
  logger.error(f"Application startup failed: {e}", exc_info=True)
777
+ fallback_gradio_app = None # Predefine for fallback
778
  try:
779
  logger.info("🔄 Falling back to Gradio-only mode...")
780
+ fallback_gradio_app = create_gradio_interface()
781
  logger.warning("⚠️ Running without request queuing in fallback mode.")
782
+ fallback_gradio_app.launch(
783
  server_name="0.0.0.0",
784
  server_port=7860,
785
  share=False,
 
789
  logger.error(f"Fallback failed: {fallback_error}", exc_info=True)
790
  print("❌ Application failed to start. Check logs for details.")
791
  finally:
792
+ if fallback_gradio_app:
793
  try:
794
+ fallback_gradio_app.close()
795
  except Exception as close_error:
796
+ logger.warning(f"Failed to close fallback Gradio app: {close_error}")
797
  finally:
798
  if gradio_app:
799
  try:
800
  gradio_app.close()
801
  except Exception as close_error:
802
+ logger.warning(f"Failed to close main Gradio app: {close_error}")
 
803
  # --- Main Entry Point ---
804
  if __name__ == "__main__":
805
  print("🧬 Gene Analysis Pipeline Starting...")