Update main.py
Browse files
main.py
CHANGED
|
@@ -4,14 +4,14 @@ from fastapi import FastAPI, UploadFile, File
|
|
| 4 |
from cnn_pipeline.pipeline import classify_tumor
|
| 5 |
from contextlib import asynccontextmanager
|
| 6 |
|
| 7 |
-
|
| 8 |
async def lifespan(app: FastAPI):
|
| 9 |
yield # The app is running at this point
|
| 10 |
-
executor.shutdown()
|
| 11 |
-
|
| 12 |
|
| 13 |
app = FastAPI(title="Brain Tumor CNN Service",lifespan=lifespan)
|
| 14 |
|
|
|
|
| 15 |
# its okay to use thead pool (prototype level) as pytorch surpasses GIL
|
| 16 |
executor=ThreadPoolExecutor(max_workers=2)
|
| 17 |
|
|
|
|
| 4 |
from cnn_pipeline.pipeline import classify_tumor
|
| 5 |
from contextlib import asynccontextmanager
|
| 6 |
|
| 7 |
+
@asynccontextmanager
|
| 8 |
async def lifespan(app: FastAPI):
|
| 9 |
yield # The app is running at this point
|
| 10 |
+
executor.shutdown(wait=True)
|
|
|
|
| 11 |
|
| 12 |
app = FastAPI(title="Brain Tumor CNN Service",lifespan=lifespan)
|
| 13 |
|
| 14 |
+
torch.set_num_threads(1)
|
| 15 |
# its okay to use thead pool (prototype level) as pytorch surpasses GIL
|
| 16 |
executor=ThreadPoolExecutor(max_workers=2)
|
| 17 |
|