diff --git a/panel/io/state.py b/panel/io/state.py index d7b3eb0e75..0685f32c40 100644 --- a/panel/io/state.py +++ b/panel/io/state.py @@ -156,7 +156,7 @@ def _thread_id(self, thread_id): def _unblocked(self, doc): thread = threading.current_thread() thread_id = thread.ident if thread else None - return doc is self.curdoc and self._thread_id == thread_id + return doc is self.curdoc and self._thread_id in (thread_id, None) @param.depends('busy', watch=True) def _update_busy(self): diff --git a/panel/reactive.py b/panel/reactive.py index 3b73f761cd..1e358b4ab2 100644 --- a/panel/reactive.py +++ b/panel/reactive.py @@ -20,12 +20,11 @@ from bokeh.models import LayoutDOM from bokeh.model import DataModel from param.parameterized import ParameterizedMetaclass, Watcher -from tornado import gen from .io.model import hold from .io.notebook import push from .io.server import unlocked -from .io.state import state +from .io.state import set_curdoc, state from .models.reactive_html import ( ReactiveHTML as _BkReactiveHTML, ReactiveHTMLParser ) @@ -278,19 +277,19 @@ def _process_events(self, events): with edit_readonly(state): state.busy = busy - @gen.coroutine - def _change_coroutine(self, doc=None): + async def _change_coroutine(self, doc=None): if state._thread_pool: state._thread_pool.submit(self._change_event, doc) else: - self._change_event(doc) + with set_curdoc(doc): + self._change_event(doc) - @gen.coroutine - def _event_coroutine(self, event): + async def _event_coroutine(self, event, doc): if state._thread_pool: state._thread_pool.submit(self._process_event, event) else: - self._process_event(event) + with set_curdoc(doc): + self._process_event(event) def _change_event(self, doc=None): try: @@ -325,12 +324,12 @@ def _comm_event(self, event): self._process_event(event) def _server_event(self, doc, event): - if doc.session_context: + if doc.session_context and not state._unblocked(doc): doc.add_next_tick_callback( - partial(self._event_coroutine, event) + partial(self._event_coroutine, event, doc) ) else: - self._process_event(event) + self._comm_event(event) def _server_change(self, doc, ref, subpath, attr, old, new): if subpath: diff --git a/panel/tests/pane/test_image.py b/panel/tests/pane/test_image.py index e9d1f42850..20d446d1d5 100644 --- a/panel/tests/pane/test_image.py +++ b/panel/tests/pane/test_image.py @@ -89,7 +89,7 @@ def test_load_from_stringio(): def test_loading_a_image_from_url(): """Tests the loading of a image from a url""" - url = 'https://file-examples-com.github.io/uploads/2017/10/file_example_PNG_500kB.png' + url = 'https://raw.githubusercontent.com/holoviz/panel/master/doc/_static/logo.png' image_pane = PNG(url) image_data = image_pane._data() @@ -114,7 +114,7 @@ def test_loading_a_image_from_pathlib(): def test_image_alt_text(document, comm): """Tests the loading of a image from a url""" - url = 'https://file-examples-com.github.io/uploads/2017/10/file_example_PNG_500kB.png' + url = 'https://raw.githubusercontent.com/holoviz/panel/master/doc/_static/logo.png' image_pane = PNG(url, embed=False, alt_text="Some alt text") model = image_pane.get_root(document, comm) @@ -124,7 +124,7 @@ def test_image_alt_text(document, comm): def test_image_link_url(document, comm): """Tests the loading of a image from a url""" - url = 'https://file-examples-com.github.io/uploads/2017/10/file_example_PNG_500kB.png' + url = 'https://raw.githubusercontent.com/holoviz/panel/master/doc/_static/logo.png' image_pane = PNG(url, embed=False, link_url="http://anaconda.org") model = image_pane.get_root(document, comm)