mekurokito / powermonitor

This is the code for the power monitoring project
0 stars 0 forks source link

Sort out AssertionErrors with getStatistics #31

Open mattsains opened 9 years ago

mattsains commented 9 years ago

Related: Issue #29

This seems to be happening a lot:

Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  22.                 return view_func(request, *args, **kwargs)
File "/home/shared/powermonitor/powermonitorweb/views.py" in graphs
  677.         current_stats = get_current_statistics()
File "/home/shared/powermonitor/powermonitorweb/views.py" in get_current_statistics
  616.     stats = scraper.get_stats()
File "/home/shared/powermonitor/Externals/PowerAlertScraper.py" in get_stats
  198.         result = self.__db.execute_query(statement=sql, data=('eskom_colour',))
File "/home/shared/powermonitor/Database/DBConnect.py" in execute_query
  49.                 query.execute(statement, data)
File "/usr/lib/python2.7/site-packages/pymysql/cursors.py" in execute
  132.         result = self._query(query)
File "/usr/lib/python2.7/site-packages/pymysql/cursors.py" in _query
  271.         conn.query(q)
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in query
  726.         self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in _read_query_result
  861.             result.read()
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in read
  1070.                 self._read_result_packet(first_packet)
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in _read_result_packet
  1110.         self._get_descriptions()
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in _get_descriptions
  1188.         assert eof_packet.is_eof_packet(), 'Protocol error, expecting EOF'

Exception Type: AssertionError at /powermonitorweb/graphs/
Exception Value: Protocol error, expecting EOF

And this:

Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  22.                 return view_func(request, *args, **kwargs)
File "/home/shared/powermonitor/powermonitorweb/views.py" in graphs
  677.         current_stats = get_current_statistics()
File "/home/shared/powermonitor/powermonitorweb/views.py" in get_current_statistics
  616.     stats = scraper.get_stats()
File "/home/shared/powermonitor/Externals/PowerAlertScraper.py" in get_stats
  210.         result = self.__db.execute_query(statement=sql, data=('eskom_level',))
File "/home/shared/powermonitor/Database/DBConnect.py" in execute_query
  49.                 query.execute(statement, data)
File "/usr/lib/python2.7/site-packages/pymysql/cursors.py" in execute
  132.         result = self._query(query)
File "/usr/lib/python2.7/site-packages/pymysql/cursors.py" in _query
  271.         conn.query(q)
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in query
  726.         self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in _read_query_result
  861.             result.read()
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in read
  1070.                 self._read_result_packet(first_packet)
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in _read_result_packet
  1109.         self.field_count = first_packet.read_length_encoded_integer()
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in read_length_encoded_integer
  334.             return unpack_int64(self.read(UNSIGNED_INT64_LENGTH))
File "/usr/lib/python2.7/site-packages/pymysql/connections.py" in read
  280.             raise AssertionError(error)

Exception Type: AssertionError at /powermonitorweb/graphs/
Exception Value: Result length not requested length:
Expected=8.  Actual=4.  Position: 1.  Data Length: 5
mattsains commented 9 years ago

status? This would be embarassing if it happens during the demo

mekurokito commented 9 years ago

As far as I can tell it only happens if you try to access the page immediately after starting up the web server. I have no immediate idea on how to fix it but I will do some investigation.

mekurokito commented 9 years ago

I have found out that it is a pymysql issue. Am busy looking at appropriate way to resolve the problem.

mekurokito commented 9 years ago

There's very little about how to overcome this issue. I think we just need to demo around this issue. It's not our fault that it occurs. As long as we can explain where the problem is we should have ourselves covered. Will leave this open in case I find a fix for it.

mattsains commented 9 years ago

I don't think we should waste sleep over it then. Good effort