grc: fixes crash when using function probe with bokehgui

This commit is contained in:
Notou 2020-04-02 17:47:50 +02:00 committed by mormj
parent 196db50915
commit 891750b4dc

View File

@ -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})