IO stream error in tornado

Hi all,

I am running a bokeh server application and updating 6 TextInput fields each 1s in a separate thread,

The update function for plotting is called each 0.5s
After a 2-3 seconds the TextInput values freezes while the update function continues

Any idea what is the reason for his?

Sometimes I am getting these errors:

ERROR:tornado.application:Future exception was never retrieved: Traceback (most recent call last):

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 168, in send_message

sent = yield message.send(self._socket)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/server/protocol/message.py”, line 192, in send

yield conn.write_message(self.content_json, locked=False)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 285, in wrapper

yielded = next(result)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 57, in write_message

write_message_unlocked()

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 44, in write_message_unlocked

future = self._socket.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 970, in write_message

return self.protocol.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 688, in write_message

return self._write_frame(True, opcode, message, flags=flags)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 671, in _write_frame

return self.stream.write(frame)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 398, in write

self._handle_write()

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 850, in _handle_write

_merge_prefix(self._write_buffer, num_bytes)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 1528, in _merge_prefix

if len(deque) == 1 and len(deque[0]) <= size:

TypeError: object of type ‘NoneType’ has no len()

ERROR:tornado.application:Future exception was never retrieved: Traceback (most recent call last):

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 168, in send_message

sent = yield message.send(self._socket)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/server/protocol/message.py”, line 180, in send

yield conn.write_message(self.header_json, locked=False)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 285, in wrapper

yielded = next(result)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 57, in write_message

write_message_unlocked()

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 44, in write_message_unlocked

future = self._socket.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 970, in write_message

return self.protocol.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 688, in write_message

return self._write_frame(True, opcode, message, flags=flags)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 671, in _write_frame

return self.stream.write(frame)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 398, in write

self._handle_write()

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 851, in _handle_write

self._write_buffer.popleft()

IndexError: pop from an empty deque

``

Hi,

It’s not really possible to speculate without knowing more details about what you are actually doing (i.e. see some code)

Thanks,

Bryan

···

On Aug 22, 2017, at 08:55, [email protected] wrote:

Hi all,

I am running a bokeh server application and updating 6 TextInput fields each 1s in a separate thread,

The update function for plotting is called each 0.5s
After a 2-3 seconds the TextInput values freezes while the update function continues

Any idea what is the reason for his?

Sometimes I am getting these errors:

ERROR:tornado.application:Future exception was never retrieved: Traceback (most recent call last):

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 168, in send_message

sent = yield message.send(self._socket)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/server/protocol/message.py”, line 192, in send

yield conn.write_message(self.content_json, locked=False)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 285, in wrapper

yielded = next(result)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 57, in write_message

write_message_unlocked()

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 44, in write_message_unlocked

future = self._socket.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 970, in write_message

return self.protocol.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 688, in write_message

return self._write_frame(True, opcode, message, flags=flags)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 671, in _write_frame

return self.stream.write(frame)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 398, in write

self._handle_write()

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 850, in _handle_write

_merge_prefix(self._write_buffer, num_bytes)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 1528, in _merge_prefix

if len(deque) == 1 and len(deque[0]) <= size:

TypeError: object of type ‘NoneType’ has no len()

ERROR:tornado.application:Future exception was never retrieved: Traceback (most recent call last):

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 168, in send_message

sent = yield message.send(self._socket)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/server/protocol/message.py”, line 180, in send

yield conn.write_message(self.header_json, locked=False)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 285, in wrapper

yielded = next(result)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 57, in write_message

write_message_unlocked()

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 44, in write_message_unlocked

future = self._socket.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 970, in write_message

return self.protocol.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 688, in write_message

return self._write_frame(True, opcode, message, flags=flags)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 671, in _write_frame

return self.stream.write(frame)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 398, in write

self._handle_write()

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 851, in _handle_write

self._write_buffer.popleft()

IndexError: pop from an empty deque

``

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e51e581a-850b-4601-b7b4-a288d9745fac%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Brian,

Here you can find an an example :

from bokeh.io import show

from bokeh.layouts import widgetbox, row, column, layout

from bokeh.models.widgets import TextInput

from bokeh.plotting import curdoc, figure

from bokeh.client import push_session

from threading import Thread

from random import randint

import time

class View():

def __init__(self):

    self.label_1 = TextInput(value = '', title = "label_1:")

    self.label_2 = TextInput(value = '', title = "label_2:")

    self.label_3 = TextInput(value = '', title = "label_3:")

    self.label_4 = TextInput(value = '', title = "label_4:")

    self.label_5 = TextInput(value = '', title = "label_5:")

    self.label_6 = TextInput(value = '', title = "label_6:")

    self.layout = row(column(widgetbox(self.label_1, width = 170), widgetbox(self.label_2, width = 170)), column(widgetbox(self.label_3, width = 170), widgetbox(self.label_4, width = 170)), column(widgetbox(self.label_5, width = 170), widgetbox(self.label_6, width = 170)))

    curdoc().add_periodic_callback(self.update, 500)

    curdoc().add_root(self.layout)

    session = push_session(document = curdoc())

    session.show(self.layout)

    self.startLoop_1()

    self.startLoop_2()

    self.startLoop_3()

    session.loop_until_closed()
···

###############################################################################

def loop_1(self):

    while True:

        print "loop_1"

        time.sleep(1)

def loop_2(self):

    while True:

        print 'loop_2'

        time.sleep(1)

def loop_3(self):

    while True:

        print 'loop_3'

        self.label_1.value = ''

        self.label_2.value = ''

        self.label_3.value = ''

        self.label_4.value = ''

        self.label_5.value = ''

        self.label_6.value = ''

        time.sleep(0.5)

        self.label_1.value = str(randint(5, 10))

        self.label_2.value = str(randint(5, 10))

        self.label_3.value = str(randint(5, 10))

        self.label_4.value = str(randint(5, 10))

        self.label_5.value = str(randint(5, 10))

        self.label_6.value = str(randint(5, 10))

        time.sleep(0.5)

################################################################################

def startLoop_1(self):

    thread = Thread(target = self.loop_1)

    thread.start()

def startLoop_2(self):

    thread = Thread(target = self.loop_2)

    thread.start()

def startLoop_3(self):

    thread = Thread(target = self.loop_3)

    thread.start()

################################################################################

def update(self):

    print

    print 'update'

    print

################################################################################

View()

``

On Tuesday, August 22, 2017 at 4:00:47 PM UTC+2, Bryan Van de ven wrote:

Hi,

It’s not really possible to speculate without knowing more details about what you are actually doing (i.e. see some code)

Thanks,

Bryan

On Aug 22, 2017, at 08:55, [email protected] wrote:

Hi all,

I am running a bokeh server application and updating 6 TextInput fields each 1s in a separate thread,

The update function for plotting is called each 0.5s
After a 2-3 seconds the TextInput values freezes while the update function continues

Any idea what is the reason for his?

Sometimes I am getting these errors:

ERROR:tornado.application:Future exception was never retrieved: Traceback (most recent call last):

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 168, in send_message

sent = yield message.send(self._socket)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/server/protocol/message.py”, line 192, in send

yield conn.write_message(self.content_json, locked=False)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 285, in wrapper

yielded = next(result)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 57, in write_message

write_message_unlocked()

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 44, in write_message_unlocked

future = self._socket.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 970, in write_message

return self.protocol.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 688, in write_message

return self._write_frame(True, opcode, message, flags=flags)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 671, in _write_frame

return self.stream.write(frame)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 398, in write

self._handle_write()

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 850, in _handle_write

_merge_prefix(self._write_buffer, num_bytes)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 1528, in _merge_prefix

if len(deque) == 1 and len(deque[0]) <= size:

TypeError: object of type ‘NoneType’ has no len()

ERROR:tornado.application:Future exception was never retrieved: Traceback (most recent call last):

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 168, in send_message

sent = yield message.send(self._socket)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/server/protocol/message.py”, line 180, in send

yield conn.write_message(self.header_json, locked=False)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 285, in wrapper

yielded = next(result)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 57, in write_message

write_message_unlocked()

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 44, in write_message_unlocked

future = self._socket.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 970, in write_message

return self.protocol.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 688, in write_message

return self._write_frame(True, opcode, message, flags=flags)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 671, in _write_frame

return self.stream.write(frame)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 398, in write

self._handle_write()

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 851, in _handle_write

self._write_buffer.popleft()

IndexError: pop from an empty deque

``

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e51e581a-850b-4601-b7b4-a288d9745fac%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

I think this code is missing the important part, namely where you try to do any updates. Those are what are causing the problem, so it would be necessary to see an example of how exactly you are trying to update the Bokeh Document. Without more information, the only thing I can speculate is that you are trying to update the Document directly from a thread, which will not work. All updates to documents have to go through the appropriate locked callback. Perhaps this User Guide section will be helpful:

  http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-threads

Bryan

···

On Aug 22, 2017, at 10:52, [email protected] wrote:

Hi Brian,

Here you can find an an example :

from bokeh.io import show
from bokeh.layouts import widgetbox, row, column, layout
from bokeh.models.widgets import TextInput
from bokeh.plotting import curdoc, figure
from bokeh.client import push_session
from threading import Thread
from random import randint
import time

class View():

    def __init__(self):
        self.label_1 = TextInput(value = '', title = "label_1:")
        self.label_2 = TextInput(value = '', title = "label_2:")
        self.label_3 = TextInput(value = '', title = "label_3:")
        self.label_4 = TextInput(value = '', title = "label_4:")
        self.label_5 = TextInput(value = '', title = "label_5:")
        self.label_6 = TextInput(value = '', title = "label_6:")

        self.layout = row(column(widgetbox(self.label_1, width = 170), widgetbox(self.label_2, width = 170)), column(widgetbox(self.label_3, width = 170), widgetbox(self.label_4, width = 170)), column(widgetbox(self.label_5, width = 170), widgetbox(self.label_6, width = 170)))

        curdoc().add_periodic_callback(self.update, 500)
        curdoc().add_root(self.layout)

        session = push_session(document = curdoc())
        session.show(self.layout)

        self.startLoop_1()
        self.startLoop_2()
        self.startLoop_3()

        session.loop_until_closed()

###############################################################################

    def loop_1(self):
        while True:
            print "loop_1"
            time.sleep(1)

    def loop_2(self):
        while True:
            print 'loop_2'
            time.sleep(1)

    def loop_3(self):
        while True:
            print 'loop_3'

            self.label_1.value = ''
            self.label_2.value = ''
            self.label_3.value = ''
            self.label_4.value = ''
            self.label_5.value = ''
            self.label_6.value = ''

            time.sleep(0.5)

            self.label_1.value = str(randint(5, 10))
            self.label_2.value = str(randint(5, 10))
            self.label_3.value = str(randint(5, 10))
            self.label_4.value = str(randint(5, 10))
            self.label_5.value = str(randint(5, 10))
            self.label_6.value = str(randint(5, 10))

            time.sleep(0.5)

################################################################################

    def startLoop_1(self):
        thread = Thread(target = self.loop_1)
        thread.start()

    def startLoop_2(self):
        thread = Thread(target = self.loop_2)
        thread.start()

    def startLoop_3(self):
        thread = Thread(target = self.loop_3)
        thread.start()

################################################################################

    def update(self):
        print
        print 'update'
        print

################################################################################

View()

On Tuesday, August 22, 2017 at 4:00:47 PM UTC+2, Bryan Van de ven wrote:
Hi,

It's not really possible to speculate without knowing more details about what you are actually doing (i.e. see some code)

Thanks,

Bryan

On Aug 22, 2017, at 08:55, [email protected] wrote:

Hi all,

I am running a bokeh server application and updating 6 TextInput fields each 1s in a separate thread,
The update function for plotting is called each 0.5s
After a 2-3 seconds the TextInput values freezes while the update function continues
Any idea what is the reason for his?

Sometimes I am getting these errors:

ERROR:tornado.application:Future exception was never retrieved: Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1021, in run
    yielded = self.gen.throw(*exc_info)
  File "/Library/Python/2.7/site-packages/bokeh/client/_connection.py", line 168, in send_message
    sent = yield message.send(self._socket)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1015, in run
    value = future.result()
  File "/Library/Python/2.7/site-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1021, in run
    yielded = self.gen.throw(*exc_info)
  File "/Library/Python/2.7/site-packages/bokeh/server/protocol/message.py", line 192, in send
    yield conn.write_message(self.content_json, locked=False)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1015, in run
    value = future.result()
  File "/Library/Python/2.7/site-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 285, in wrapper
    yielded = next(result)
  File "/Library/Python/2.7/site-packages/bokeh/client/_connection.py", line 57, in write_message
    write_message_unlocked()
  File "/Library/Python/2.7/site-packages/bokeh/client/_connection.py", line 44, in write_message_unlocked
    future = self._socket.write_message(message, binary)
  File "/Library/Python/2.7/site-packages/tornado/websocket.py", line 970, in write_message
    return self.protocol.write_message(message, binary)
  File "/Library/Python/2.7/site-packages/tornado/websocket.py", line 688, in write_message
    return self._write_frame(True, opcode, message, flags=flags)
  File "/Library/Python/2.7/site-packages/tornado/websocket.py", line 671, in _write_frame
    return self.stream.write(frame)
  File "/Library/Python/2.7/site-packages/tornado/iostream.py", line 398, in write
    self._handle_write()
  File "/Library/Python/2.7/site-packages/tornado/iostream.py", line 850, in _handle_write
    _merge_prefix(self._write_buffer, num_bytes)
  File "/Library/Python/2.7/site-packages/tornado/iostream.py", line 1528, in _merge_prefix
    if len(deque) == 1 and len(deque[0]) <= size:
TypeError: object of type 'NoneType' has no len()

ERROR:tornado.application:Future exception was never retrieved: Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1021, in run
    yielded = self.gen.throw(*exc_info)
  File "/Library/Python/2.7/site-packages/bokeh/client/_connection.py", line 168, in send_message
    sent = yield message.send(self._socket)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1015, in run
    value = future.result()
  File "/Library/Python/2.7/site-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1021, in run
    yielded = self.gen.throw(*exc_info)
  File "/Library/Python/2.7/site-packages/bokeh/server/protocol/message.py", line 180, in send
    yield conn.write_message(self.header_json, locked=False)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 1015, in run
    value = future.result()
  File "/Library/Python/2.7/site-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "/Library/Python/2.7/site-packages/tornado/gen.py", line 285, in wrapper
    yielded = next(result)
  File "/Library/Python/2.7/site-packages/bokeh/client/_connection.py", line 57, in write_message
    write_message_unlocked()
  File "/Library/Python/2.7/site-packages/bokeh/client/_connection.py", line 44, in write_message_unlocked
    future = self._socket.write_message(message, binary)
  File "/Library/Python/2.7/site-packages/tornado/websocket.py", line 970, in write_message
    return self.protocol.write_message(message, binary)
  File "/Library/Python/2.7/site-packages/tornado/websocket.py", line 688, in write_message
    return self._write_frame(True, opcode, message, flags=flags)
  File "/Library/Python/2.7/site-packages/tornado/websocket.py", line 671, in _write_frame
    return self.stream.write(frame)
  File "/Library/Python/2.7/site-packages/tornado/iostream.py", line 398, in write
    self._handle_write()
  File "/Library/Python/2.7/site-packages/tornado/iostream.py", line 851, in _handle_write
    self._write_buffer.popleft()
IndexError: pop from an empty deque

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e51e581a-850b-4601-b7b4-a288d9745fac%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/482e8a05-f40a-4d2d-a28e-43d988aa32ef%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I think this is it.
All document updates should be done in the update function and not in a separate thread.

Thank you!

···

On Tuesday, August 22, 2017 at 6:06:21 PM UTC+2, Bryan Van de ven wrote:

Hi,

I think this code is missing the important part, namely where you try to do any updates. Those are what are causing the problem, so it would be necessary to see an example of how exactly you are trying to update the Bokeh Document. Without more information, the only thing I can speculate is that you are trying to update the Document directly from a thread, which will not work. All updates to documents have to go through the appropriate locked callback. Perhaps this User Guide section will be helpful:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-threads](http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-threads)

Bryan

On Aug 22, 2017, at 10:52, [email protected] wrote:

Hi Brian,

Here you can find an an example :

from bokeh.io import show

from bokeh.layouts import widgetbox, row, column, layout

from bokeh.models.widgets import TextInput

from bokeh.plotting import curdoc, figure

from bokeh.client import push_session

from threading import Thread

from random import randint

import time

class View():

def __init__(self):
    self.label_1 = TextInput(value = '', title = "label_1:")
    self.label_2 = TextInput(value = '', title = "label_2:")
    self.label_3 = TextInput(value = '', title = "label_3:")
    self.label_4 = TextInput(value = '', title = "label_4:")
    self.label_5 = TextInput(value = '', title = "label_5:")
    self.label_6 = TextInput(value = '', title = "label_6:")
    self.layout = row(column(widgetbox(self.label_1, width = 170), widgetbox(self.label_2, width = 170)), column(widgetbox(self.label_3, width = 170), widgetbox(self.label_4, width = 170)), column(widgetbox(self.label_5, width = 170), widgetbox(self.label_6, width = 170)))
    curdoc().add_periodic_callback(self.update, 500)
    curdoc().add_root(self.layout)
    session = push_session(document = curdoc())
    session.show(self.layout)
    self.startLoop_1()
    self.startLoop_2()
    self.startLoop_3()
    session.loop_until_closed()

###############################################################################

def loop_1(self):
    while True:
        print "loop_1"
        time.sleep(1)
def loop_2(self):
    while True:
        print 'loop_2'
        time.sleep(1)
def loop_3(self):
    while True:
        print 'loop_3'
        self.label_1.value = ''
        self.label_2.value = ''
        self.label_3.value = ''
        self.label_4.value = ''
        self.label_5.value = ''
        self.label_6.value = ''
        time.sleep(0.5)
        self.label_1.value = str(randint(5, 10))
        self.label_2.value = str(randint(5, 10))
        self.label_3.value = str(randint(5, 10))
        self.label_4.value = str(randint(5, 10))
        self.label_5.value = str(randint(5, 10))
        self.label_6.value = str(randint(5, 10))
        time.sleep(0.5)

################################################################################

def startLoop_1(self):
    thread = Thread(target = self.loop_1)
    thread.start()
def startLoop_2(self):
    thread = Thread(target = self.loop_2)
    thread.start()
def startLoop_3(self):
    thread = Thread(target = self.loop_3)
    thread.start()

################################################################################

def update(self):
    print
    print 'update'
    print

################################################################################

View()

On Tuesday, August 22, 2017 at 4:00:47 PM UTC+2, Bryan Van de ven wrote:

Hi,

It’s not really possible to speculate without knowing more details about what you are actually doing (i.e. see some code)

Thanks,

Bryan

On Aug 22, 2017, at 08:55, [email protected] wrote:

Hi all,

I am running a bokeh server application and updating 6 TextInput fields each 1s in a separate thread,

The update function for plotting is called each 0.5s

After a 2-3 seconds the TextInput values freezes while the update function continues

Any idea what is the reason for his?

Sometimes I am getting these errors:

ERROR:tornado.application:Future exception was never retrieved: Traceback (most recent call last):

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 168, in send_message

sent = yield message.send(self._socket)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/server/protocol/message.py”, line 192, in send

yield conn.write_message(self.content_json, locked=False)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 285, in wrapper

yielded = next(result)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 57, in write_message

write_message_unlocked()

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 44, in write_message_unlocked

future = self._socket.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 970, in write_message

return self.protocol.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 688, in write_message

return self._write_frame(True, opcode, message, flags=flags)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 671, in _write_frame

return self.stream.write(frame)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 398, in write

self._handle_write()

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 850, in _handle_write

_merge_prefix(self._write_buffer, num_bytes)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 1528, in _merge_prefix

if len(deque) == 1 and len(deque[0]) <= size:

TypeError: object of type ‘NoneType’ has no len()

ERROR:tornado.application:Future exception was never retrieved: Traceback (most recent call last):

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 168, in send_message

sent = yield message.send(self._socket)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1021, in run

yielded = self.gen.throw(*exc_info)

File “/Library/Python/2.7/site-packages/bokeh/server/protocol/message.py”, line 180, in send

yield conn.write_message(self.header_json, locked=False)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 1015, in run

value = future.result()

File “/Library/Python/2.7/site-packages/tornado/concurrent.py”, line 237, in result

raise_exc_info(self._exc_info)

File “/Library/Python/2.7/site-packages/tornado/gen.py”, line 285, in wrapper

yielded = next(result)

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 57, in write_message

write_message_unlocked()

File “/Library/Python/2.7/site-packages/bokeh/client/_connection.py”, line 44, in write_message_unlocked

future = self._socket.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 970, in write_message

return self.protocol.write_message(message, binary)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 688, in write_message

return self._write_frame(True, opcode, message, flags=flags)

File “/Library/Python/2.7/site-packages/tornado/websocket.py”, line 671, in _write_frame

return self.stream.write(frame)

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 398, in write

self._handle_write()

File “/Library/Python/2.7/site-packages/tornado/iostream.py”, line 851, in _handle_write

self._write_buffer.popleft()

IndexError: pop from an empty deque


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e51e581a-850b-4601-b7b4-a288d9745fac%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/482e8a05-f40a-4d2d-a28e-43d988aa32ef%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.