Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
[app] Parent process - use an even better solution
Browse files Browse the repository at this point in the history
This is the official method by the mp module, which should work across all OSes (hopefully..)
  • Loading branch information
igiloh-pinecone committed Nov 5, 2023
1 parent 8227d84 commit 6f4b0a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/canopy_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import uuid

import openai
from multiprocessing import current_process
from multiprocessing import current_process, parent_process

import yaml
from dotenv import load_dotenv
Expand Down Expand Up @@ -232,7 +232,7 @@ async def shutdown() -> ShutdownResponse:
""" # noqa: E501
logger.info("Shutting down")
proc = current_process()
pid = os.getppid() if "SpawnProcess" in proc.name else proc.pid
pid = parent_process().pid if parent_process() else proc.pid
os.kill(pid, signal.SIGINT)
return ShutdownResponse()

Expand Down

0 comments on commit 6f4b0a1

Please sign in to comment.