Hello,
I am a newbie in blokeh, so this can be an easy problem for you perhaps. I am trying to write an app to display stock prices on browser.
In the code I created an source:
source.stream(dict(close_time=close_time, open=open, close=close, high=high, low=low, inc=inc, dec=dec))
And with a while loop I am trying to get new price in every 5 seconds and trying to update the price bar.
To do so first I code checks if new price is not same with previous price and if it is different than creates a patch dictionary:
if close_new[-1] != close[-1]:
patches_1_1 ={'close': [(len(close)-1, close_new[-1])]}
Than, updating the source:
source.patch(patches_1_1)
When I write len(close)
it throws an index error, which is strange, and I thought it can be different indexing in patch so I chosed (len(close)-1
. There is a len(close)-1
index eventually. This is not a problem in anyway.
But this code creates a very long error:
File "C:\ProgramData\Anaconda3\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\ProgramData\Anaconda3\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\milik\PycharmProjects\Interview\price.py", line 114, in blocking_task
source.patch(patches_1_1)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\models\sources.py", line 684, in patch
self.data._patch(self.document, self, patches, setter)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\property\wrappers.py", line 470, in _patch
self._notify_owners(old,
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\property\wrappers.py", line 150, in _notify_owners
descriptor._notify_mutated(owner, old, hint=hint)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\property\descriptors.py", line 869, in _notify_mutated
self._real_set(obj, old, value, hint=hint)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\property\descriptors.py", line 832, in _real_set
self._trigger(obj, old, value, hint=hint, setter=setter)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\core\property\descriptors.py", line 909, in _trigger
obj.trigger(self.name, old, value, hint, setter)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\model.py", line 664, in trigger
super().trigger(attr, old, new, hint=hint, setter=setter)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\util\callback_manager.py", line 157, in trigger
self._document._notify_change(self, attr, old, new, hint, setter, invoke)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\document\document.py", line 1061, in _notify_change
self._trigger_on_change(event)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\document\document.py", line 1156, in _trigger_on_change
self._with_self_as_curdoc(invoke_callbacks)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\document\document.py", line 1169, in _with_self_as_curdoc
return f()
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\document\document.py", line 1155, in invoke_callbacks
cb(event)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\document\document.py", line 723, in <lambda>
self._callbacks[receiver] = lambda event: event.dispatch(receiver)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\document\events.py", line 269, in dispatch
super().dispatch(receiver)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\document\events.py", line 124, in dispatch
receiver._document_patched(self)
File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\server\session.py", line 218, in _document_patched
raise RuntimeError("_pending_writes should be non-None when we have a document lock, and we should have the lock when the document changes")
In the source there are several columns but I need to update only one value in one column in a time.
What am I missing?