When I install googletrans
into the most barebones flask_socketio
server, running the server gives me Invalid async_mode specified
.
Here is the basic Flask app:
from flask import Flask
from flask_socketio import SocketIO
app = Flask(__name__)
socketio = SocketIO(app=app, cors_allowed_origins="*")
if __name__ == '__main__':
socketio.run(app, host="0.0.0.0", port=3001)
It uses this Pipfile:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
flask="*"
flask-socketio = "*"
[dev-packages]
[requires]
python_version = "3.11"
pipenv install
and pipenv run python app.py
works fine.
How it Breaks
But, if you pipenv install googletrans
and pipenv run python app.py
, it breaks:
Broken Pipfile
[packages]
flask="*"
flask-socketio = "*"
googletrans="*"
Response
Traceback (most recent call last):
File "C:\Users\User\Documents\git\flask-socket-test\app.py", line 5, in <module>
socketio = SocketIO(app=app, cors_allowed_origins="*")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\.virtualenvs\flask-socket-test-RBuOQeqq\Lib\site-packages\flask_socketio\__init__.py", line 187, in __init__
self.init_app(app, **kwargs)
File "C:\Users\User\.virtualenvs\flask-socket-test-RBuOQeqq\Lib\site-packages\flask_socketio\__init__.py", line 243, in init_app
self.server = socketio.Server(**self.server_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\.virtualenvs\flask-socket-test-RBuOQeqq\Lib\site-packages\socketio\base_server.py", line 31, in __init__
self.eio = self._engineio_server_class()(**engineio_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\.virtualenvs\flask-socket-test-RBuOQeqq\Lib\site-packages\engineio\base_server.py", line 81, in __init__
raise ValueError('Invalid async_mode specified')
ValueError: Invalid async_mode specified
Is it googletrans
or its dependencies?
I looked at what packages googletrans
depends on, to see if it was its dependencies or google translate itself.
I froze the requirements of the failing google translate build, removed google translate, and I was left with this pipfile:
[packages]
flask="*"
flask-socketio = "*"
certifi="*"
chardet="*"
h2="*"
hpack="*"
hstspreload="*"
httpcore="*"
httpx="*"
hyperframe="*"
idna="*"
rfc3986="*"
anyio="*"
sniffio="*"
I pipenv uninstall -all
'd, installed this, ran it, and it did not throw the anync error therefore the issue is in the googletrans package itself.