Skip to content

Commit

Permalink
fix: more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Oct 7, 2023
1 parent fa92dee commit 70a0458
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
4 changes: 3 additions & 1 deletion htagweb/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ async def killall():
running_hids:list=await bus.get(KEYAPPS) or []
if str(hid) in running_hids:
log("Try to reuse process",hid)
assert await bus.publish(hid.event_interact,dict(cmd=CMD_REUSE,params=params))
can = await bus.publish(hid.event_interact,dict(cmd=CMD_REUSE,params=params))
if not can:
log("Can't answer the interaction REUSE !!!!")
else:
p=multiprocessing.Process(target=process, args=[],kwargs=params)
p.start()
Expand Down
23 changes: 13 additions & 10 deletions htagweb/server/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,19 @@ async def interact(self,**params) -> dict:
""" return htag'actions or None (if process doesn't answer, after timeout)
(dialog with process event)
"""
# subscribe for response
await self.bus.subscribe( self.hid.event_interact_response )

# 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 {}
else:
self.error(f"Can't publish {self.hid.event_interact} !!!")

try:
# subscribe for response
await self.bus.subscribe( self.hid.event_interact_response )

# 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 {}
else:
self.error(f"Can't publish {self.hid.event_interact} !!!")
except Exception as e:
self.error("***HrClient.interact error***",e)
return {}


async def main():
Expand Down

0 comments on commit 70a0458

Please sign in to comment.