Hi All,
I seem to be running into a memory issue after leaving my live streaming app on for a number of hours. Any ideas? Here is my code.
class LiveGrapher: #Observer
def __init__(self, observable):
self.datasetsDisplayed = observable.registerObserver(self)
self.source = {}
self.colors = ['grey', 'yellow', 'LightSkyBlue', 'red', 'green', 'blue','AliceBlue', 'AniqueWhite', 'Aqua', 'Aquamarine', 'Azure', 'Beige', 'Bisque']
for item in self.datasetsDisplayed:
self.source[item] = ColumnDataSource(data=dict(x=[], y=[], dateStampStr = [], timeStampStr = [], key = []))
self.doc = curdoc()
def notify(self, observable, *args, **kwargs):
timeStamp = ''
YKey = ''
YVal = 0
timeStamp = kwargs['timeStamp'] - datetime.timedelta(hours=5)
for key in kwargs.keys():
if key in self.datasetsDisplayed:
YVal = kwargs[key]
self.doc.add_next_tick_callback(partial(self.update, x=timeStamp, y=YVal, key =key))
def update(self, x, y, key):
self.source[key].stream(dict(x=[x], y=[y], key = [key], dateStampStr=[x.strftime('%m/%d/%Y')], timeStampStr=[x.strftime('%H:%M:%S')]), 30)
def draw(self):
drawTools = [BoxZoomTool(), ResetTool(), HoverTool( tooltips=[('key', '@key'), ('date', '@dateStampStr'), ('time', '@timeStampStr'), ('value' , '@y')])]
now = datetime.datetime.now()
#hourandMinute = now.strftime("%H:%M")
#titlef = "DLHV Live Analysis for the past 1 Hour" %hourandMinute
p = figure(title="DLHV Live Analysis for the past 1 Hour", x_axis_type="datetime", x_axis_label='Time', y_axis_label = 'Value',y_range=[0,2000], tools=drawTools, plot_width=1000)
colorID = 0
for dataset in self.datasetsDisplayed:
p.line(x='x', y='y', legend = dataset, source=self.source[dataset], line_color=self.colors[colorID])
#p.square(x='x', y='y', legend= dataset, source=self.source[dataset], fill_color=None, line_color=self.colors[colorID])
colorID = colorID + 1
p.legend.location = "top_right"
p.legend.background_fill_color = "grey"
p.legend.background_fill_alpha = 0.5
self.doc.add_root(p)
#ecuAddress = raw_input(“Please enter ECU Address:”)
dlhvMonitor1 = DlhvMonitor(‘10.215.21.136’)
lg1 = LiveGrapher(dlhvMonitor1)
lg1.draw()
thread = Thread(target = dlhvMonitor1.startDataRetrieval)
thread.start()
and here is the log:
lambda future: self.add_callback(callback, future))
File “c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\ioloop.py”,
line 962, in add_callback
stack_context.wrap(callback), *args, **kwargs))
MemoryError
2017-01-21
09:42:06,334 Exception in callback <functools.partial object at
0x7889E340>
Traceback
(most recent call last):
File “c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\ioloop.py”,
line 619, in _run_callback
self.add_future(ret, lambda f: f.result())
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\ioloop.py”,
line 596, in add_future
lambda future: self.add_callback(callback, future))
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\concurrent.py”,
line 265, in add_done_callback
fn(self)
File “c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\ioloop.py”,
line 596, in
lambda future: self.add_callback(callback, future))
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\ioloop.py”,
line 962, in add_callback
stack_context.wrap(callback), *args, **kwargs))
MemoryError
2017-01-21
09:44:11,214 Uncaught exception GET
/liveGrapher/ws?bokeh-protocol-version=1.0&bokeh-session-id=77vu529pcuD3g2mE3fnhAN6Z2o3zqlDkxgEtzZSKyG
s
(::1)
HTTPServerRequest(protocol=‘http’,
host=‘localhost:5006’, method=‘GET’,
uri=’/liveGrapher/ws?bokeh-protocol-version=1.0&bokeh-session-id=77vu529pcuD3
2mE3fnhAN6Z2o3zqlDkxgEtzZSKyGZs’,
version=‘HTTP/1.1’, remote_ip=’::1’, headers={‘Origin’:
‘http://localhost:5006’, ‘Upgrade’: ‘websocket’, 'Accept-La
guage’:
‘en-US,en;q=0.8’, ‘Accept-Encoding’: ‘gzip, deflate, sdch, br’,
‘Sec-Websocket-Version’: ‘13’, ‘Host’: ‘localhost:5006’, ‘Sec-Websocket-Key’:
‘VdOVoDLpWbJPKT+DeFXb1Q==’,
‘User-Agent’: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/55.0.2883.87 Safari/537.
6’,
‘Connection’: ‘Upgrade’, ‘Pragma’: ‘no-cache’, ‘Cache-Control’: ‘no-cache’,
‘Sec-Websocket-Extensions’: 'permessage-deflate; client_max_window_bi
s’})
Traceback
(most recent call last):
File “c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\web.py”,
line 1425, in _stack_context_handle_exception
raise_exc_info((type, value, traceback))
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\stack_context.py”,
line 314, in wrapped
ret = fn(*args, **kwargs)
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\websocket.py”,
line 741, in _on_frame_length_16
self.stream.read_bytes(4, self._on_masking_key)
File “c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\iostream.py”,
line 317, in read_bytes
self._try_inline_read()
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\iostream.py”,
line 699, in _try_inline_read
self._read_from_buffer(pos)
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\iostream.py”,
line 770, in _read_from_buffer
self._run_read_callback(pos, False)
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\iostream.py”,
line 682, in _run_read_callback
self._run_callback(callback, self._consume(size))
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\iostream.py”,
line 583, in _run_callback
self.io_loop.add_callback(wrapper)
File “c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\ioloop.py”,
line 962, in add_callback
stack_context.wrap(callback), *args, **kwargs))
MemoryError
2017-01-21
09:44:11,838 Exception in callback <functools.partial object at
0x66B87720>
Traceback
(most recent call last):
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\ioloop.py”,
line 619, in _run_callback
self.add_future(ret, lambda f: f.result())
File “c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\ioloop.py”,
line 596, in add_future
lambda future: self.add_callback(callback, future))
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\concurrent.py”,
line 265, in add_done_callback
fn(self)
File “c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\ioloop.py”,
line 596, in
lambda future: self.add_callback(callback, future))
File
“c:\python27\lib\site-packages\tornado-4.4.2-py2.7-win32.egg\tornado\ioloop.py”,
line 962, in add_callback
stack_context.wrap(callback), *args, **kwargs))
MemoryError