redis-py raises AttributeError - redis-py

In what circumstances would redis-py raise the following AttributeError exception?
Isn't redis-py built by design to raise only redis.exceptions.RedisError based exceptions?
What would be a reasonable handling logic?
Traceback (most recent call last):
File "c:\Python27\Lib\", line 551, in __bootstrap_inner
File "c:\Python27\Lib\", line 504, in run
self.__target(*self.__args, **self.__kwargs)
File C:\Users\Administrator\Documents\my_proj\", line 33, in inner
ret = protected_func(*args, **kwargs)
File C:\Users\Administrator\Documents\my_proj\", line 104, in _listen
for message in _pubsub.listen():
File "C:\Users\Administrator\virtual_environments\my_env\lib\site-packages\redis\", line 1555, in listen
r = self.parse_response()
File "C:\Users\Administrator\virtual_environments\my_env\lib\site-packages\redis\", line 1499, in parse_response
response = self.connection.read_response()
File "C:\Users\Administrator\virtual_environments\my_env\lib\site-packages\redis\", line 306, in read_response
response = self._parser.read_response()
File "C:\Users\Administrator\virtual_environments\my_env\lib\site-packages\redis\", line 104, in read_response
response =
File "C:\Users\Administrator\virtual_environments\my_env\lib\site-packages\redis\", line 89, in read
return self._fp.readline()[:-2]
AttributeError: 'NoneType' object has no attribute 'readline'

seems like an old question, but I faced the same problem recently.
My setup was using celery with redis as a broker. A ThreadPoolExecutor uses the shared celery object to batch tasks to workers. The batcher function waits for the submitted tasks to finish using celery.result.ResultSet.
After quick investigations, I found that celery somewhere uses a pub/sub mechanism to wait for the tasks to finish. And that is it, pub/sub don't play well with thread-safety per the official readme
Honestly, I didn't try to prove my theory and fixed my problem by switching to a ProcessPoolExecutor instead.


Convert trained Tensorflow model to a TensorFlow.JS model (Inception trained model)

I'm trying to use transfer learning to train the inception model from google and get the output that I want and use it with tensaflowJS. The outputs should be angry or smiling
By following the tutorial TensorFlow For Poets I trained the CNN and I already has the model .pb.
Now, I'm following this tutorial and I used this command:
tensorflowjs_converter --input_format=tf_frozen_model --output_node_names='angry,smiling' --saved_model_tags=serve retrained_graph.pb web_model
But I'm getting the following error:
Traceback (most recent call last): File
line 193, in _run_module_as_main
"main", mod_spec) File "c:\users\ricardo\appdata\local\programs\python\python36\lib\",
line 85, in _run_code
exec(code, run_globals) File "C:\Users\Ricardo\AppData\Local\Programs\Python\Python36\Scripts\",
line 9, in File
line 272, in main
strip_debug_ops=FLAGS.strip_debug_ops) File "c:\users\ricardo\appdata\local\programs\python\python36\lib\site-packages\tensorflowjs\converters\",
line 323, in convert_tf_frozen_model
graph = load_graph(frozen_model_path, output_node_names) File "c:\users\ricardo\appdata\local\programs\python\python36\lib\site-packages\tensorflowjs\converters\",
line 67, in load_graph
graph.get_operation_by_name(node.strip())) File "c:\users\ricardo\appdata\local\programs\python\python36\lib\site-packages\tensorflow\python\framework\",
line 3616, in get_operation_by_name
return self.as_graph_element(name, allow_tensor=False, allow_operation=True) File
line 3488, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File
line 3548, in _as_graph_element_locked
"graph." % repr(name)) KeyError: 'The name "\'angry" refers to an Operation not in the graph.'
Anyone know what I'm doing wrong?

How to manage errors with bokeh library (Python + JavaScript) and show them on the user interface?

I am working in a Bokeh Server Application using the Python library "Bokeh" and I usually get two types of errors.
JavaScript errors on the Chromium console
Python errors on the server side, they appear in the Tornado logger. Bokeh works with the Tornado Web Server
What I could achieve is to create manual exceptions inheriting the Exception class in python. In this way I can write custom messages and run some actions when the error is raised with this class.
class ManualException(Exception):
def __init__(self, value):
self.value = value
# some actions
def __str__(self):
return repr(
'MANUAL ERROR\n' + self.value
But if any other exception occurs then I do not know how to capture them to run some custom actions. I have tried this:
n = 9 / 0
except Exception:
tb = sys.exc_info()[2]
raise ManualException('ZERO ERROR').with_traceback(tb)
Here I have to catch any error manually and I raise them with my manual created class, then both appear in the python logger. Is this the proper way to do this?
2017-09-04 17:08:58,872 Error running application handler < object at 0x0000023E2435C208>: 'MANUAL ERROR\nZERO ERROR'
File "", line 11, in <module>:
n = 9 / 0 Traceback (most recent call last):
File "[...]\", line 11, in <module>
n = 9 / 0
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "[...]\lib\site-packages\bokeh\application\handlers\", line 125, in run
exec(self._code, module.__dict__)
File "[...]\", line 14, in <module>
raise ManualException('ZERO ERROR').with_traceback(tb)
File "[...]\", line 11, in <module>
n = 9 / 0
exceptions.ManualException: 'MANUAL ERROR\n'ZERO ERROR'
Anyway I want avoid this because I want to show all kind of errors to the user, even if I do not use try-except to capture exceptions.
On the other hand if a python error happens, a JavaScript message is shown. So I think the best option is to override some JavaScript method to run some custom js code. How could I achieve this? Is this achievable?

Unable to run pykalma example code that is reading MAT file with scipy

Below is the line of the code that pykalman example is using to load the matlab file robot.mat. However, it is throwing an error with message ValueError: Unknown mat file type, version 100, 110.
I am new to reading matlab files in Python. Can anyone help me understand exactly what version it is expecting and how to get around the issue?
data = io.loadmat(join(module_path, 'data', 'robot.mat'))
Traceback (most recent call last):
File "C:\ProgramData\Anaconda2\lib\site-
packages\IPython\core\", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-0439d709929f>", line 1, in <module>
data = load_robot()
File "C:\ProgramData\Anaconda2\lib\site-packages\pykalman\datasets\",
line 45, in load_robot
data = io.loadmat(join(module_path, 'data', 'robot.mat'))
File "C:\ProgramData\Anaconda2\lib\site-packages\scipy\io\matlab\",
line 135, in loadmat
MR = mat_reader_factory(file_name, appendmat, **kwargs)
File "C:\ProgramData\Anaconda2\lib\site-packages\scipy\io\matlab\",
line 59, in mat_reader_factory
mjv, mnv = get_matfile_version(byte_stream)
File "C:\ProgramData\Anaconda2\lib\site-
line 241, in get_matfile_version
raise ValueError('Unknown mat file type, version %s, %s' % ret)
ValueError: Unknown mat file type, version 100, 110
I'm guessing here (and adding one more idea to hpaulj's good overview):
First i checked the file manually and opening in an editor reads as:
MATLAB 5.0 MAT-file, Platform: MACI64, Created on: Tue Jun 26 00:59:04 2012
Therefore there should be no problem in regards to scipy (if the mat-file is actually following this "header").
Now it seems there are some open issues with that project with the most relevant beeing:
Unable to load robot.mat #59
(Don't be surprised too much with the different eror-values as i would expect possibly indeterministic stuff like that when bad IO is beeing done)
and: pykalman/datasets/ not copied when pykalman is installed with pip #66
So it seems this dataset does not come with pip-install automatically, which looks like your problem and should be easily handled (manually obtaining the data!). It is also compatible with hpaulj's wondering about that strange error (one could argue if there is no better error-handling possible).

Webdriver in Python - Executing Function from External Script

How do I execute a function located in an external JavaScript using webdriver in python?
The JavaScript is used to overwrite JavaScripts internal DateTime object to give an
altered browser time for unit testing.
I like to use sinonfaketimers.js for this purpose. (But would also go with alternatives
like TimeShift.js)
Links: ,
So I wrote the following python code, which calls the JavaScript itself but not the respective function:
driver = webdriver.Firefox()
# some code here to test shift in time
As far as I understand this matter correctly all I need to do in order to make
this work is to run the respective JavaScript function with the correct arguments.
I assume passing the arguments could be done by building a suitable string like:
driver.execute_script("function('" + argument_var + "');")
The actual function inside the JavaScript sinon_timers.js is:
sinon.timers = {
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setImmediate: (typeof setImmediate !== "undefined" ? setImmediate : undefined),
clearImmediate: (typeof clearImmediate !== "undefined" ? clearImmediate: undefined),
setInterval: setInterval,
clearInterval: clearInterval,
Date: Date
The full length script can be found at
But I am not sure about the syntax of calling the function sinon.timers in sinon_timers.js.
How do I do that?
Sainath Motlakunta suggested a solution. Unfortunately it doesn't work.
But maybe we are closer a step to cracking the puzzle:
driver = webdriver.Firefox()
driver.execute_script(open("./sinon_timers.js").read()) # <- is this line important?
driver.execute_script("var clock = sinon.useFakeTimers(12345);")
This yields: selenium.common.exceptions.WebDriverException: Message: sinon is not defined
Full traceback:
Traceback (most recent call last):
File "/path/", line 47, in <module>
File "/path/", line 37, in sinon_test
driver.execute_script("var clock = sinon.useFakeTimers(12345);")
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 401, in execute_script
{'script': script, 'args':converted_args})['value']
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 173, in execute
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 166, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: sinon is not defined
Is there maybe some useful information in this post, asking exactly the same question?:
The proposed solution sketched is:
List item Inject/Add the mocking framework during tests runs
Mock the Date object with the JavaScript Executor
Set the timezone
Run tests

Container not found: goog.Disposable.instances_ error while using leak-finder-for-javascript tool

I m using leak-finder-for-javascript tool to find memory leak in javascript.
For this m using Python 2.5 on Windows 7
INFO:root:Using leak definition closure-disposable
INFO:root:Reading suppressions from "closure-disposable-suppressions.txt"
INFO:root:Taking heap snapshot
INFO:root:Analyzing heap snapshot
ERROR:root:Error analyzing snapshot: <class 'leak_finder.Error'>
Traceback (most recent call last):
File "", line 345, in <module>
File "", line 340, in main
result = leak_checker.Run(inspector_client)
File "", line 151, in Run
leaks = self._FindLeaks(client)
File "", line 189, in _FindLeaks
File "C:\Projects\retail\depot_tools\file\leak-finder\src\", lin
e 571, in FindLeaks
raise Error('Container not found: %s' % edge_description)
leak_finder.Error: Container not found: goog.Disposable.instances_
When i try to check goog.Disposable.instances_ in chrome console it shows me the object which has a leak but then it shows this error.
The issue is discussed in the bug tracker:
Most probable reasons for this error message:
You're inspecting a wrong page (Leak Finder always inspects the first tab; having developer tools open on that tab confuses it).
You're trying to use the Closure leak definition with a page which doesn't use Closure.