http is K

master
bel 2023-03-25 22:18:46 -06:00
parent ade19ea36b
commit f271040e47
1 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import signal
import sys
from os import environ
from os import kill
import requests
def main():
managerToParserQ = queue.Queue(maxsize=1)
@ -176,6 +177,9 @@ class Actor(threading.Thread):
elif environ.get("SIGUSR2", ""):
self.pid = int(environ["SIGUSR2"])
self.handle = self.handle_signal
elif environ.get("URL", ""):
self.url = environ["URL"]
self.handle = self.handle_url
def run(self):
log("Actor.run: start")
@ -197,5 +201,12 @@ class Actor(threading.Thread):
self.handle_stderr(hotword, context)
kill(self.pid, signal.SIGUSR2)
def handle_url(self, hotword, context):
self.handle_stderr(hotword, context)
try:
requests.post(self.url, json={"hotword":hotword, "context":context})
except Exception as e:
log("Actor.handle_url:", e)
if __name__ == "__main__":
main()