Commit 1a272212 authored by olivier R-D's avatar olivier R-D

respect TimeoutHint for PublishRequest

parent b92c2817
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import logging import logging
from threading import Lock from threading import Lock
from datetime import datetime from datetime import datetime
import time
from opcua import ua from opcua import ua
from opcua.common import utils from opcua.common import utils
...@@ -13,6 +14,7 @@ class PublishRequestData(object): ...@@ -13,6 +14,7 @@ class PublishRequestData(object):
self.requesthdr = None self.requesthdr = None
self.algohdr = None self.algohdr = None
self.seqhdr = None self.seqhdr = None
self.timestamp = time.time()
class UaProcessor(object): class UaProcessor(object):
...@@ -52,10 +54,14 @@ class UaProcessor(object): ...@@ -52,10 +54,14 @@ class UaProcessor(object):
def forward_publish_response(self, result): def forward_publish_response(self, result):
self.logger.info("forward publish response %s", result) self.logger.info("forward publish response %s", result)
with self._datalock: with self._datalock:
if len(self._publishdata_queue) == 0: while True:
self.logger.warning("Error server wants to send publish answer but no publish request is available") if len(self._publishdata_queue) == 0:
return self.logger.warning("Error server wants to send publish answer but no publish request is available")
requestdata = self._publishdata_queue.pop(0) return
requestdata = self._publishdata_queue.pop(0)
if time.time() - requestdata.timestamp < requestdata.requesthdr.TimeoutHint / 1000:
break
response = ua.PublishResponse() response = ua.PublishResponse()
response.Parameters = result response.Parameters = result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment