http is K
parent
ade19ea36b
commit
f271040e47
|
|
@ -6,6 +6,7 @@ import signal
|
||||||
import sys
|
import sys
|
||||||
from os import environ
|
from os import environ
|
||||||
from os import kill
|
from os import kill
|
||||||
|
import requests
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
managerToParserQ = queue.Queue(maxsize=1)
|
managerToParserQ = queue.Queue(maxsize=1)
|
||||||
|
|
@ -176,6 +177,9 @@ class Actor(threading.Thread):
|
||||||
elif environ.get("SIGUSR2", ""):
|
elif environ.get("SIGUSR2", ""):
|
||||||
self.pid = int(environ["SIGUSR2"])
|
self.pid = int(environ["SIGUSR2"])
|
||||||
self.handle = self.handle_signal
|
self.handle = self.handle_signal
|
||||||
|
elif environ.get("URL", ""):
|
||||||
|
self.url = environ["URL"]
|
||||||
|
self.handle = self.handle_url
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
log("Actor.run: start")
|
log("Actor.run: start")
|
||||||
|
|
@ -197,5 +201,12 @@ class Actor(threading.Thread):
|
||||||
self.handle_stderr(hotword, context)
|
self.handle_stderr(hotword, context)
|
||||||
kill(self.pid, signal.SIGUSR2)
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue