Michael S. Trusov commited on
Commit
932e2b4
·
1 Parent(s): f05a578

July 18 commit to Hugging Face 10:48pm

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -32,6 +32,8 @@ def download_file(filename: str, directory: str = "."):
32
  print(f"File found: {file_path}")
33
  return FileResponse(path=file_path, filename=filename)
34
 
 
 
35
  def run_fastapi():
36
  import uvicorn
37
  from uvicorn import Config, Server
@@ -44,15 +46,19 @@ def run_fastapi():
44
  server = CustomServer(config=config)
45
 
46
  print("Starting FastAPI server... Version 4:51pm")
47
-
48
- try:
49
- print("In try block before server.run")
50
- server.run()
51
- print("In try block after server.run")
52
- except Exception as e:
53
- print(f"Failed to start FastAPI server: {e}")
54
- finally:
55
- print("Exiting run_fastapi function")
 
 
 
 
56
 
57
  #--------------------------------------------------------------------------------
58
 
 
32
  print(f"File found: {file_path}")
33
  return FileResponse(path=file_path, filename=filename)
34
 
35
+ import multiprocessing
36
+
37
  def run_fastapi():
38
  import uvicorn
39
  from uvicorn import Config, Server
 
46
  server = CustomServer(config=config)
47
 
48
  print("Starting FastAPI server... Version 4:51pm")
49
+
50
+ def start_server():
51
+ try:
52
+ print("In start_server before server.run")
53
+ server.run()
54
+ print("In start_server after server.run")
55
+ except Exception as e:
56
+ print(f"Failed to start FastAPI server: {e}")
57
+
58
+ p = multiprocessing.Process(target=start_server)
59
+ p.start()
60
+ print("Server process started")
61
+
62
 
63
  #--------------------------------------------------------------------------------
64