Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: unhashable type: 'dict' against SID #408

Closed
gordol opened this issue Feb 17, 2017 · 7 comments
Closed

TypeError: unhashable type: 'dict' against SID #408

gordol opened this issue Feb 17, 2017 · 7 comments
Assignees
Labels

Comments

@gordol
Copy link

gordol commented Feb 17, 2017

Any ideas?

2017-02-17 12:35:21,532 - c222819e8b8d4f77a6e4e10c0dd07157: Received packet MESSAGE data 2/analytics,["save_analytics_view",{DATAOBFUSCATED},"name":"Test"}]
2017-02-17 12:35:21,549 - received event "save_analytics_view" from c222819e8b8d4f77a6e4e10c0dd07157 [/analytics]
Exception in thread Thread-19:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/tinix/.virtualenvs/7g/lib/python2.7/site-packages/socketio/server.py", line 433, in _handle_event_internal
    r = server._trigger_event(data[0], namespace, sid, *data[1:])
  File "/Users/tinix/.virtualenvs/7g/lib/python2.7/site-packages/socketio/server.py", line 462, in _trigger_event
    return self.handlers[namespace][event](*args)
  File "/Users/tinix/.virtualenvs/7g/lib/python2.7/site-packages/flask_socketio/__init__.py", line 213, in _handler
    *args)
  File "/Users/tinix/.virtualenvs/7g/lib/python2.7/site-packages/flask_socketio/__init__.py", line 574, in _handle_event
    ret = handler(*args)
  File "/Users/tinix/.virtualenvs/7g/lib/python2.7/site-packages/flask_socketio/__init__.py", line 213, in _handler
    *args)
  File "/Users/tinix/.virtualenvs/7g/lib/python2.7/site-packages/flask_socketio/__init__.py", line 558, in _handle_event
    if sid not in self.server.environ:
TypeError: unhashable type: 'dict'

@miguelgrinberg
Copy link
Owner

Can you show me the output of pip freeze please?

@gordol
Copy link
Author

gordol commented Feb 17, 2017

Sure, no problem...

--local is okay, right?

» pip freeze --local
amqp==2.1.0
anyjson==0.3.3
apns==2.0.1
appy==0.9.4
attrdict==2.0.0
beautifulsoup4==4.5.1
billiard==3.5.0.1
biplist==1.0.1
blinker==1.4
boto3==1.4.3
botocore==1.4.93
CacheControl==0.11.7
cffi==1.8.2
clamd==1.0.2
click==6.6
click-plugins==1.0.3
cligj==0.4.0
closure==20160517
cssmin==0.2.0
cssutils==1.0.1
decorator==4.0.10
dill==0.2.5
docutils==0.13.1
enum34==1.1.6
eventlet==0.19.0
Flask==0.11.1
Flask-Admin==1.4.2
Flask-Assets==0.12
Flask-Bower==1.2.1
Flask-Cache==0.13.1
Flask-Cors==3.0.2
Flask-JWT==0.3.2
Flask-Login==0.3.2
Flask-Mail==0.9.1
flask-mongoengine==0.7.5
Flask-Principal==0.4.0
Flask-Script==2.0.5
Flask-Security==1.7.5
Flask-SocketIO==2.7.2
Flask-WTF==0.12
futures==3.0.5
geocoder==1.19.0
gitdb==0.6.4
GitPython==2.0.8
greenlet==0.4.10
gspread==0.4.1
gunicorn==19.6.0
htmlmin==0.1.10
httplib2==0.9.2
idna==2.1
ImageHash==2.2
inflect==0.2.5
ipaddress==1.0.17
iso3166==0.7
itsdangerous==0.24
jdcal==1.2
Jinja2==2.9.5
jmespath==0.9.0
jsmin==2.2.1
kombu==3.0.35
libipa==0.0.6
mapbox==0.10.1
markdown2==2.3.3
MarkupSafe==0.23
mongoengine==0.10.6
MonthDelta==0.9.1
natsort==5.0.1
numpy==1.11.1
oauth2client==1.5.2
pandas==0.18.1
passlib==1.6.5
Paste==2.0.3
PasteDeploy==1.5.2
Pillow==3.3.1
polyline==1.3.1
prettyprint==0.1.5
pudb==2016.2
py==1.4.32
py-dateutil==2.2
pyasn1==0.1.9
pyasn1-modules==0.0.8
pyClamd==0.3.17
pycparser==2.14
pycrypto==2.6.1
Pygments==2.1.3
PyJWT==1.4.2
pymongo==3.3.0
pyPdf==1.13
python-dateutil==2.5.3
python-engineio==1.0.3
python-magic==0.4.12
python-socketio==1.6.0
pytz==2016.6.1
PyWavelets==0.4.0
ratelim==0.1.6
redis==2.10.5
repoze.lru==0.6
requests==2.11.1
Routes==2.3.1
rsa==3.4.2
s3transfer==0.1.10
scipy==0.18.0
secretary==0.2.14
six==1.10.0
smmap==0.9.0
uritemplate==3.0.0
urwid==1.3.1
vine==1.1.2
webassets==0.12.0
WebOb==1.6.1
Werkzeug==0.11.11
WTForms==2.1
xlrd==1.0.0
XlsxWriter==0.9.6

@miguelgrinberg
Copy link
Owner

Thanks. That was just so that I can lookup the versions of the packages you were using.

Is there anything odd in how your save_analytics_view event handler is constructed? Do you have multiple @socketio.on decorators on that function, for example?

@miguelgrinberg miguelgrinberg self-assigned this Feb 17, 2017
@gordol
Copy link
Author

gordol commented Feb 17, 2017

Is there anything odd in how your save_analytics_view event handler is constructed?

Kinda...

@socketio.on('save_analytics_view', namespace='/analytics')
@socketio.on('save_analytics_view', namespace='/analytics/summary')
@login_required
def analytics_save_analytics_view(data):
    ...

Do you have multiple @socketio.on decorators on that function, for example?

Yep...

That's exactly what is causing it, actually. :)

I commented out the /analytics/summary decorator as seen above, and now it works...

If I add two decorators, it seems to break, both receiving, and sending of socket messages by the wrapped methods. The socket.io server receives messages from the client, but they don't get routed to the handlers, and it seems the server thinks it's sending the messages, but they are never received by the client either.

This is a trivial fix on my end, it'll just cause a little duplicated code to have one handler for each namespace.

@gordol
Copy link
Author

gordol commented Feb 17, 2017

# todo: wtf, sometimes recv_sid doesn't exist in listeners, but it did above to get to this point? race condition?

i forgot about this until now... i believe there are some other bugs floating around here in regards to sid being missing too... hmm.

but the way it's used here has nothing to do w/ SIO i think...

@miguelgrinberg
Copy link
Owner

@gordol just pushed version 2.8.4. Please upgrade to that to get this bug fixed (and make sure all the dependencies are also upgraded).

@gordol
Copy link
Author

gordol commented Feb 17, 2017

pip handles dependency upgrades, right? just tested, works great! thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants