summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grc/blocks/variable_function_probe.block.yml22
1 files changed, 16 insertions, 6 deletions
diff --git a/grc/blocks/variable_function_probe.block.yml b/grc/blocks/variable_function_probe.block.yml
index 2f93d89806..5cd3329c40 100644
--- a/grc/blocks/variable_function_probe.block.yml
+++ b/grc/blocks/variable_function_probe.block.yml
@@ -31,12 +31,22 @@ templates:
import time
import threading
var_make: self.${id} = ${id} = ${value}
- make: "\ndef _${id}_probe():\n while True:\n <% obj = 'self' + ('.'\
- \ + block_id if block_id else '') %>\n val = ${obj}.${function_name}(${function_args})\n\
- \ try:\n self.set_${id}(val)\n except AttributeError:\n\
- \ pass\n time.sleep(1.0 / (${poll_rate}))\n_${id}_thread\
- \ = threading.Thread(target=_${id}_probe)\n_${id}_thread.daemon = True\n_${id}_thread.start()\n\
- \ "
+ make: |+
+ def _${id}_probe():
+ while True:
+ <% obj = 'self' + ('.' + block_id if block_id else '') %>
+ val = ${obj}.${function_name}(${function_args})
+ try:
+ try:
+ self.doc.add_next_tick_callback(functools.partial(self.set_${id},val))
+ except AttributeError:
+ self.set_${id}(val)
+ except AttributeError:
+ pass
+ time.sleep(1.0 / (${poll_rate}))
+ _${id}_thread = threading.Thread(target=_${id}_probe)
+ _${id}_thread.daemon = True
+ _${id}_thread.start()
callbacks:
- self.set_${id}(${value})