Python-socketio: Python 2.7 broken due to threading.main_thread() call in client.py

Created on 24 Mar 2020  路  6Comments  路  Source: miguelgrinberg/python-socketio

When I try to run the example client code the following is thrown

Traceback (most recent call last):
  File "client1.py", line 4, in <module>
    sio = socketio.Client()
  File "[path to local lib]/python2.7/site-packages/socketio/client.py", line 88, in __init__
    threading.current_thread() == threading.main_thread():
AttributeError: 'module' object has no attribute 'main_thread'

In client.py on line 88 a call is made to threading.main_thread() which appears to be a Python 3-only call available on the threading module.

https://docs.python.org/2/library/threading.html

question

Most helpful comment

another workaround is to install an older version of this library, 4.2.1 worked for me.

pip uninstall python-socketio
pip install -Iv python-socketio==4.2.1

All 6 comments

I have stopped building and testing 2.7 a while ago, so it is expected that incompatible features are going to start appearing in the code base. I don't really see a good reason to keep maintaining 2.7 going forward, in fact I plan to clean up the code at some point and remove 2.7 only code paths.

That's fair. The docs just make a point that it's compatible with both so that's why I submitted the issue. I'll close this. Thanks for the fast response.

I need to remove the 2.7 reference from the docs, thanks for pointing that out.

@miguelgrinberg i am having the same issue, is it possible to make a fix manualy or something, i am counting on this awesome library but cant upgrade to python 3

@zur250 I show a manual workaround in a video I made that might work for you. Here is a timestamped start into the video at the part where I make the change. It's a small tweak and worked for me.
https://youtu.be/ZEsuIQgsORc?t=209

another workaround is to install an older version of this library, 4.2.1 worked for me.

pip uninstall python-socketio
pip install -Iv python-socketio==4.2.1
Was this page helpful?
0 / 5 - 0 ratings