- # send out all messages waiting for us
- while not self.instance_send_queue.empty():
- work_item = self.instance_send_queue.get(block=False, timeout=None)
- payload = json.dumps(messages.a1_to_handler(*work_item)).encode("utf-8")
- self._send_msg(payload, A1_POLICY_REQUEST, work_item[1])
+ # Update 3/20/2020
+ # We now handle our sends in a thread (that will just exit when it's done) because there is a difference between how send works in SI95 vs NNG.
+ # Send_msg via NNG formerly never blocked.
+ # However under SI95 this send may block for some arbitrary period of time on the first send to an endpoint for which a connection is not established
+ # If this send takes too long, this loop blocks, and the healthcheck will fail, which will cause A1s healthcheck to fail, which will cause Kubernetes to whack A1 and all kinds of horrible things happen.
+ # Therefore, now under SI95, we thread this.
+ Thread(target=self._handle_sends).start()