koenverhagen commited on
Commit
f9adf74
1 Parent(s): 6a53fd5

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +4 -2
server.py CHANGED
@@ -23,6 +23,7 @@ allow_headers=["*"], # Allows all headers
23
  # API_TOKEN = os.environ["API_TOKEN"]
24
  API_TOKEN = '34dsadfF$$%#$TGREGEFGE%Q*)(*&%'
25
 
 
26
 
27
  # ---------------------------------------------------------------------------
28
  # - Token auth method -
@@ -73,9 +74,10 @@ async def resolution(request : Request, background_tasks: BackgroundTasks, respo
73
 
74
  image = io.BytesIO(await data.read())
75
  image.seek(0)
 
76
  background_tasks.add_task(check_gpu_usage)
77
  result = cardtagger(image.read())
78
-
79
  background_tasks.add_task(delete_old_files)
80
 
81
  return result
@@ -88,7 +90,7 @@ async def resolution(request : Request, background_tasks: BackgroundTasks, respo
88
 
89
  def check_gpu_usage():
90
  try:
91
- while True:
92
  output = subprocess.check_output("nvidia-smi", shell=True).decode("utf-8")
93
  # lines = output.split('\n')
94
  #
 
23
  # API_TOKEN = os.environ["API_TOKEN"]
24
  API_TOKEN = '34dsadfF$$%#$TGREGEFGE%Q*)(*&%'
25
 
26
+ card_is_running = False
27
 
28
  # ---------------------------------------------------------------------------
29
  # - Token auth method -
 
74
 
75
  image = io.BytesIO(await data.read())
76
  image.seek(0)
77
+ card_is_running = True
78
  background_tasks.add_task(check_gpu_usage)
79
  result = cardtagger(image.read())
80
+ card_is_running = False
81
  background_tasks.add_task(delete_old_files)
82
 
83
  return result
 
90
 
91
  def check_gpu_usage():
92
  try:
93
+ while card_is_running:
94
  output = subprocess.check_output("nvidia-smi", shell=True).decode("utf-8")
95
  # lines = output.split('\n')
96
  #