Fix unresponsive 'redis-py' client operation #1785

Closed
jeff1evesque opened this Issue Apr 10, 2015 · 8 comments

Comments

Projects
None yet
1 participant
Owner

jeff1evesque commented Apr 10, 2015

When we attempt a mode_generate session, using an existing svm dataset, from the database, the browser becomes unresponsive. Specifically, the browser is stuck within an ajax request (infinite spinner), while no error is produced via the browser debug console, and no errors is printed within the dedicated terminal console for app.py (python flask):

unresponsive

So, we attempt to run a simplified test case, using the redis set, instead of the hset operation, via a terminal console:

$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sklearn import svm
>>> import redis
>>> X = [[0], [1], [2], [3]]
>>> Y = [0, 1, 2, 3]
>>> clf = svm.SVC()
>>> clf.fit(X, Y) 
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.0,
  kernel='rbf', max_iter=-1, probability=False, random_state=None,
  shrinking=True, tol=0.001, verbose=False)
>>> clf
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.0,
  kernel='rbf', max_iter=-1, probability=False, random_state=None,
  shrinking=True, tol=0.001, verbose=False)
>>> import cPickle as pickle
>>> serialized = pickle.dumps(clf)
>>> serialized
"ccopy_reg\n_reconstructor\np1\n(csklearn.svm.classes\nSVC\np2\nc__builtin__\nobject\np3\nNtRp4\n(dp5\nS'_impl'\np6\nS'c_svc'\np7\nsS'kernel'\np8\nS'rbf'\np9\nsS'verbose'\np10\nI00\nsS'probability'\np11\nI00\nsS'classes_'\np12\ncnumpy.core.multiarray\n_reconstruct\np13\n(cnumpy\nndarray\np14\n(I0\ntS'b'\ntRp15\n(I1\n(I4\ntcnumpy\ndtype\np16\n(S'i8'\nI0\nI1\ntRp17\n(I3\nS'<'\nNNNI-1\nI-1\nI0\ntbI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\ntbsS'support_'\np18\ng13\n(g14\n(I0\ntS'b'\ntRp19\n(I1\n(I4\ntg16\n(S'i4'\nI0\nI1\ntRp20\n(I3\nS'<'\nNNNI-1\nI-1\nI0\ntbI00\nS'\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x03\\x00\\x00\\x00'\ntbsS'dual_coef_'\np21\ng13\n(g14\n(I0\ntS'b'\ntRp22\n(I1\n(I3\nI4\ntg16\n(S'f8'\nI0\nI1\ntRp23\n(I3\nS'<'\nNNNI-1\nI-1\nI0\ntbI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf'\ntbsS'shrinking'\np24\nI01\nsS'class_weight'\np25\nNsS'_gamma'\np26\nF1\nsS'probA_'\np27\ng13\n(g14\n(I0\ntS'b'\ntRp28\n(I1\n(I0\ntg23\nI00\nS''\ntbsS'_sparse'\np29\nI00\nsS'class_weight_'\np30\ng13\n(g14\n(I0\ntS'b'\ntRp31\n(I1\n(I4\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?'\ntbsS'random_state'\np32\nNsS'tol'\np33\nF0.001\nsS'coef0'\np34\nF0\nsS'nu'\np35\nF0\nsS'n_support_'\np36\ng13\n(g14\n(I0\ntS'b'\ntRp37\n(I1\n(I4\ntg20\nI00\nS'\\x01\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x01\\x00\\x00\\x00'\ntbsS'shape_fit_'\np38\n(I4\nI1\ntp39\nsS'C'\nF1\nsS'support_vectors_'\np40\ng13\n(g14\n(I0\ntS'b'\ntRp41\n(I1\n(I4\nI1\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\x00@\\x00\\x00\\x00\\x00\\x00\\x00\\x08@'\ntbsS'degree'\np42\nI3\nsS'epsilon'\np43\nF0\nsS'max_iter'\np44\nI-1\nsS'fit_status_'\np45\nI0\nsS'_intercept_'\np46\ng13\n(g14\n(I0\ntS'b'\ntRp47\n(I1\n(I6\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\ntbsS'intercept_'\np48\ng13\n(g14\n(I0\ntS'b'\ntRp49\n(I1\n(I6\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\ntbsS'probB_'\np50\ng13\n(g14\n(I0\ntS'b'\ntRp51\n(I1\n(I0\ntg23\nI00\nS''\ntbsS'cache_size'\np52\nI200\nsS'gamma'\np53\nF0\nsb."
>>> pool = redis.ConnectionPool(host='localhost', port=5000, db=0)
>>> myRedis = redis.StrictRedis(connection_pool=pool)
>>> myRedis.set('svm_model', serialized)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1055, in set
    return self.execute_command('SET', *pieces)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 571, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 577, in parse_response
    response = connection.read_response()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 569, in read_response
    response = self._parser.read_response()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 224, in read_response
    response = self._buffer.readline()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 162, in readline
    self._read_from_socket()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 137, in _read_from_socket
    (e.args,))
redis.exceptions.ConnectionError: Error while reading from socket: ('Connection closed by server.',)

## Traceback for 'app.py' in terminal (note: 'app.py' runs on port 5000)
$ python app.py
 * Running on http://127.0.0.1:5000/
 * Restarting with reloader
127.0.0.1 - - [10/Apr/2015 07:01:36] code 400, message Bad request syntax ('*3')
127.0.0.1 - - [10/Apr/2015 07:01:36] "*3" 400 -
127.0.0.1 - - [10/Apr/2015 07:01:36] code 400, message Bad request syntax ('*3')
127.0.0.1 - - [10/Apr/2015 07:01:36] "*3" 400 -

# Attempt on redis default port (defined within redis.conf#L60)
>>> pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
>>> myRedis = redis.StrictRedis(connection_pool=pool)
>>> myRedis.set('svm_model', serialized)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1055, in set
    return self.execute_command('SET', *pieces)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 570, in execute_command
    connection.send_command(*args)
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 556, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 532, in send_packed_command
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 436, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.


## Traceback for 'app.py' in terminal remains unchanged (note: 'app.py' runs on port 5000)
$ python app.py
 * Running on http://127.0.0.1:5000/
 * Restarting with reloader
127.0.0.1 - - [10/Apr/2015 07:01:36] code 400, message Bad request syntax ('*3')
127.0.0.1 - - [10/Apr/2015 07:01:36] "*3" 400 -
127.0.0.1 - - [10/Apr/2015 07:01:36] code 400, message Bad request syntax ('*3')
127.0.0.1 - - [10/Apr/2015 07:01:36] "*3" 400 -

Note: the installation technique for our Ubuntu 14.04 machine can be found within the Redis wiki page.

Owner

jeff1evesque commented Apr 10, 2015

When we attempt to remove the use of the Connection Pool while on port 5000 (port used for the current running python flask app.py) in the terminal console window:

...
>>> myRedis = redis.StrictRedis(host='localhost', port=5000, db=0)
>>> myRedis.set('svm_model', serialized)

the console is unresponsive, and no error traceback is produced within the other dedicated terminal console running flask on port 5000. So, we execute ctrl-c within the non-flask terminal console, with the above commands:

...
>>> myRedis = redis.StrictRedis(host='localhost', port=5000, db=0)
>>> myRedis.set('svm_model', serialized)
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1055, in set
    return self.execute_command('SET', *pieces)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 565, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 577, in parse_response
    response = connection.read_response()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 569, in read_response
    response = self._parser.read_response()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 224, in read_response
    response = self._buffer.readline()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 162, in readline
    self._read_from_socket()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 120, in _read_from_socket
    data = self._sock.recv(socket_read_size)
KeyboardInterrupt

Now, we attempt to run the redis-py client without the Connection Pool on the redis-server default port 6379:

...
>>> myRedis = redis.StrictRedis(host='localhost', port=6379, db=0)
>>> serialized
"ccopy_reg\n_reconstructor\np1\n(csklearn.svm.classes\nSVC\np2\nc__builtin__\nobject\np3\nNtRp4\n(dp5\nS'_impl'\np6\nS'c_svc'\np7\nsS'kernel'\np8\nS'rbf'\np9\nsS'verbose'\np10\nI00\nsS'probability'\np11\nI00\nsS'classes_'\np12\ncnumpy.core.multiarray\n_reconstruct\np13\n(cnumpy\nndarray\np14\n(I0\ntS'b'\ntRp15\n(I1\n(I4\ntcnumpy\ndtype\np16\n(S'i8'\nI0\nI1\ntRp17\n(I3\nS'<'\nNNNI-1\nI-1\nI0\ntbI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\ntbsS'support_'\np18\ng13\n(g14\n(I0\ntS'b'\ntRp19\n(I1\n(I4\ntg16\n(S'i4'\nI0\nI1\ntRp20\n(I3\nS'<'\nNNNI-1\nI-1\nI0\ntbI00\nS'\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x03\\x00\\x00\\x00'\ntbsS'dual_coef_'\np21\ng13\n(g14\n(I0\ntS'b'\ntRp22\n(I1\n(I3\nI4\ntg16\n(S'f8'\nI0\nI1\ntRp23\n(I3\nS'<'\nNNNI-1\nI-1\nI0\ntbI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf'\ntbsS'shrinking'\np24\nI01\nsS'class_weight'\np25\nNsS'_gamma'\np26\nF1\nsS'probA_'\np27\ng13\n(g14\n(I0\ntS'b'\ntRp28\n(I1\n(I0\ntg23\nI00\nS''\ntbsS'_sparse'\np29\nI00\nsS'class_weight_'\np30\ng13\n(g14\n(I0\ntS'b'\ntRp31\n(I1\n(I4\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?'\ntbsS'random_state'\np32\nNsS'tol'\np33\nF0.001\nsS'coef0'\np34\nF0\nsS'nu'\np35\nF0\nsS'n_support_'\np36\ng13\n(g14\n(I0\ntS'b'\ntRp37\n(I1\n(I4\ntg20\nI00\nS'\\x01\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x01\\x00\\x00\\x00'\ntbsS'shape_fit_'\np38\n(I4\nI1\ntp39\nsS'C'\nF1\nsS'support_vectors_'\np40\ng13\n(g14\n(I0\ntS'b'\ntRp41\n(I1\n(I4\nI1\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\x00@\\x00\\x00\\x00\\x00\\x00\\x00\\x08@'\ntbsS'degree'\np42\nI3\nsS'epsilon'\np43\nF0\nsS'max_iter'\np44\nI-1\nsS'fit_status_'\np45\nI0\nsS'_intercept_'\np46\ng13\n(g14\n(I0\ntS'b'\ntRp47\n(I1\n(I6\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\ntbsS'intercept_'\np48\ng13\n(g14\n(I0\ntS'b'\ntRp49\n(I1\n(I6\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\ntbsS'probB_'\np50\ng13\n(g14\n(I0\ntS'b'\ntRp51\n(I1\n(I0\ntg23\nI00\nS''\ntbsS'cache_size'\np52\nI200\nsS'gamma'\np53\nF0\nsb."
>>> myRedis.set('svm_model', serialized)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1055, in set
    return self.execute_command('SET', *pieces)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 570, in execute_command
    connection.send_command(*args)
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 556, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 532, in send_packed_command
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 436, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
Owner

jeff1evesque commented Apr 10, 2015

Some changes can be made within settings.py. Specifically, we will change the constant PORT to PORT_FLASK, and add PORT_REDIS=6379. This will require the following files to be adjusted:

Note: redis default port 6379 is defined within redis.conf.

Owner

jeff1evesque commented Apr 10, 2015

We check, and find that our redis-server is not autostarting via Ubuntu upstart:

$ ps aux | grep redis
jeffrey   25007  0.0  0.0  11740   936 pts/0    S+   08:05   0:00 grep --color=auto redis

We do not see a redis-server process from the above listing, only the grep process trying to search for the redis-server. In fact, when we attempt to shutdown redis-server:

$ sudo stop redis-server
[sudo] password for jeffrey: 
stop: Unknown instance: 

However, if we manually start the redis-server, then we finally have such a process running:

~$ sudo start redis-server
redis-server start/running, process 2984
jeffrey@ubuntu-14:~$ ps aux | grep redis
redis     2984  0.0  0.1  35244  7412 ?        Ssl  11:15   0:00 /usr/bin/redis-server *:6379               
jeffrey    2989  0.0  0.0  11740   932 pts/4    S+   11:15   0:00 grep --color=auto redis
Owner

jeff1evesque commented Apr 10, 2015

When attempting to determine the version of our redis-server, we determine it's 3.0.0 (the 2 prefix. is the epoch version number)

$ dpkg -s redis-server
Package: redis-server
Status: install ok installed
Priority: optional
Section: database
Installed-Size: 1828
Maintainer: Rowan Wookey <admin@rwky.net>
Architecture: amd64
Source: redis
Version: 2:3.0.0-rwky1~trusty
Depends: sysv-rc (>= 2.88dsf-24) | file-rc (>= 0.8.16), libc6 (>= 2.14), adduser
Suggests: redis-doc
Conffiles:
 /etc/redis/redis.conf c5c9bacf3320932267a4388b2f2b989c
 /etc/logcheck/ignore.d.server/redis-server f4663a8f65f437f41a49d132fb0b3acc
 /etc/init/redis-server.conf 4de889cdedf520c7e318a2bd879acbb3
 /etc/logrotate.d/redis-server f428fada7f18bf8b90eb6146f07109dd
Description: Persistent key-value database with network interface
 Redis is a key-value database in a similar vein to memcache but the dataset
 is non-volatile. Redis additionally provides native support for atomically
 manipulating and querying data structures such as lists and sets.
 .
 The dataset is stored entirely in memory and periodically flushed to disk.
Homepage: http://code.google.com/p/redis/
Owner

jeff1evesque commented Apr 10, 2015

We got the redis-server to autostart via Ubuntu's upstart, by commenting out the only line in /etc/init/redis-server.override:

#manual
Owner

jeff1evesque commented Apr 10, 2015

We are now able to successfully run the earlier simplified test case, using the redis set, instead of the hset operation, via a terminal console:

$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sklearn import svm
>>> import redis
>>> X = [[0], [1], [2], [3]]
>>> Y = [0, 1, 2, 3]
>>> clf = svm.SVC()
>>> clf.fit(X, Y) 
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.0,
  kernel='rbf', max_iter=-1, probability=False, random_state=None,
  shrinking=True, tol=0.001, verbose=False)
>>> import cPickle as pickle
>>> serialized = pickle.dumps(clf)
>>> serialized
"ccopy_reg\n_reconstructor\np1\n(csklearn.svm.classes\nSVC\np2\nc__builtin__\nobject\np3\nNtRp4\n(dp5\nS'_impl'\np6\nS'c_svc'\np7\nsS'kernel'\np8\nS'rbf'\np9\nsS'verbose'\np10\nI00\nsS'probability'\np11\nI00\nsS'classes_'\np12\ncnumpy.core.multiarray\n_reconstruct\np13\n(cnumpy\nndarray\np14\n(I0\ntS'b'\ntRp15\n(I1\n(I4\ntcnumpy\ndtype\np16\n(S'i8'\nI0\nI1\ntRp17\n(I3\nS'<'\nNNNI-1\nI-1\nI0\ntbI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\ntbsS'support_'\np18\ng13\n(g14\n(I0\ntS'b'\ntRp19\n(I1\n(I4\ntg16\n(S'i4'\nI0\nI1\ntRp20\n(I3\nS'<'\nNNNI-1\nI-1\nI0\ntbI00\nS'\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x03\\x00\\x00\\x00'\ntbsS'dual_coef_'\np21\ng13\n(g14\n(I0\ntS'b'\ntRp22\n(I1\n(I3\nI4\ntg16\n(S'f8'\nI0\nI1\ntRp23\n(I3\nS'<'\nNNNI-1\nI-1\nI0\ntbI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\xbf'\ntbsS'shrinking'\np24\nI01\nsS'class_weight'\np25\nNsS'_gamma'\np26\nF1\nsS'probA_'\np27\ng13\n(g14\n(I0\ntS'b'\ntRp28\n(I1\n(I0\ntg23\nI00\nS''\ntbsS'_sparse'\np29\nI00\nsS'class_weight_'\np30\ng13\n(g14\n(I0\ntS'b'\ntRp31\n(I1\n(I4\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?'\ntbsS'random_state'\np32\nNsS'tol'\np33\nF0.001\nsS'coef0'\np34\nF0\nsS'nu'\np35\nF0\nsS'n_support_'\np36\ng13\n(g14\n(I0\ntS'b'\ntRp37\n(I1\n(I4\ntg20\nI00\nS'\\x01\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x01\\x00\\x00\\x00'\ntbsS'shape_fit_'\np38\n(I4\nI1\ntp39\nsS'C'\nF1\nsS'support_vectors_'\np40\ng13\n(g14\n(I0\ntS'b'\ntRp41\n(I1\n(I4\nI1\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\x00\\x00\\x00\\x00@\\x00\\x00\\x00\\x00\\x00\\x00\\x08@'\ntbsS'degree'\np42\nI3\nsS'epsilon'\np43\nF0\nsS'max_iter'\np44\nI-1\nsS'fit_status_'\np45\nI0\nsS'_intercept_'\np46\ng13\n(g14\n(I0\ntS'b'\ntRp47\n(I1\n(I6\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\ntbsS'intercept_'\np48\ng13\n(g14\n(I0\ntS'b'\ntRp49\n(I1\n(I6\ntg23\nI00\nS'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\ntbsS'probB_'\np50\ng13\n(g14\n(I0\ntS'b'\ntRp51\n(I1\n(I0\ntg23\nI00\nS''\ntbsS'cache_size'\np52\nI200\nsS'gamma'\np53\nF0\nsb."
>>> pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
>>> myRedis = redis.StrictRedis(connection_pool=pool)
>>> myRedis.set('svm_model', serialized)
True
Owner

jeff1evesque commented Apr 10, 2015

We need to resolve the following ResponseError:

$ python app.py
 * Running on http://127.0.0.1:5000/
 * Restarting with reloader
127.0.0.1 - - [10/Apr/2015 15:39:42] "POST /load-data/ HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/var/www/web_interface/views.py", line 40, in load_data
    elif session_type == 'model_generate': response = loader.load_model_generate()
  File "/var/www/brain/load_data.py", line 96, in load_model_generate
    session.generate_model()
  File "/var/www/brain/session/model_generate.py", line 84, in generate_model
    Cache_Model(clf).cache('svm_model', 'model_' + str(self.session_id))
  File "/var/www/brain/cache/cache_model.py", line 27, in cache
    self.myRedis.hset(hash_name, key, serialized)
  File "/var/www/brain/cache/redis_query.py", line 173, in hset
    self.server.hset(name, key, value)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1853, in hset
    return self.execute_command('HSET', name, key, value)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 565, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 577, in parse_response
    response = connection.read_response()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 574, in read_response
    raise response
ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value
Owner

jeff1evesque commented Apr 10, 2015

The latter problem was a result of an existing string-typed cache with the same existing key svm_model. When we performed the redis .delete('svm_model'), the successive attempt worked.

jeff1evesque added a commit that referenced this issue Apr 10, 2015

Merge pull request #1786 from jeff1evesque/redis
#1785: Fix unresponsive 'redis-py' client operation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment