summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
authorNotou <barthy42@laposte.net>2020-04-02 17:47:50 +0200
committermormj <34754695+mormj@users.noreply.github.com>2020-05-29 14:58:02 -0400
commit5a2983534fa1faac49528aa41c6cacad806a70d8 (patch)
tree271bfc2ac6dc9340a7762aea423b5fa51a07c274 /grc
parent27f54cb643a0105c2035284afd274865bd9e3238 (diff)
grc: fixes crash when using function probe with bokehgui
Diffstat (limited to 'grc')
-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})