Skip to content

Commit

Permalink
fix: kill process when timeout 1min
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Oct 8, 2023
1 parent 9bead55 commit 5ee5394
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions htagweb/server/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import uuid,asyncio,time,sys
import redys
import redys.v2
from htagweb.server import CMD_RESP_RECREATE, CMD_RESP_RENDER, CMD_PS_REUSE, KEYAPPS,Hid, hrprocess
from htagweb.server import CMD_RESP_RECREATE, CMD_RESP_RENDER, CMD_PS_REUSE, KEYAPPS,Hid, hrprocess, ServerClient
import logging
logger = logging.getLogger(__name__)

TIMEOUT=2*60 # A interaction can take 2min max
TIMEOUT=1*60 # A interaction can take 1min max


def startProcess(params:dict):
Expand Down Expand Up @@ -87,8 +87,10 @@ async def start(self,*a,**k) -> str:
# the process has giver a right answer ... return the rendering
return message.get("render")


self.error(f"Event TIMEOUT ({TIMEOUT}s) on {self.hid.event_response} !!!")
return "?!"
await ServerClient().kill(self.hid)
return f"Timeout: App {self.hid.fqn} killed !"



Expand All @@ -103,7 +105,7 @@ async def interact(self,**params) -> dict:
# post the interaction
if await self.bus.publish( self.hid.event_interact, params ):
# wait actions
return await self._wait(self.hid.event_interact_response) or {}
return await self._wait(self.hid.event_interact_response) or dict(error=f"Timeout: App {self.hid.fqn} killed !")
else:
self.error(f"Can't publish {self.hid.event_interact} !!!")
except Exception as e:
Expand All @@ -119,4 +121,5 @@ async def _wait(self,event, s=TIMEOUT):
return message

self.error(f"Event TIMEOUT ({s}s) on {event} !!!")
await ServerClient().kill(self.hid)
return None

0 comments on commit 5ee5394

Please sign in to comment.