Description
I'm running a python script that has a very large path
, sys.argv[0] = /home/myuser/.cache/bazel/_bazel_myuser/86d86849c94045e321482e95af59d89a/execroot/mymonorepo/bazel-out/k8-fastbuild/bin/src/applications/myapp/myapp.runfiles/mymonorepo/src/applications/myapp/src/server.py
. This is because the application uses bazel as a monorepo manager.
But this causes aiomysql
to fail to run :
File "/home/myuser/.cache/bazel/_bazel_myuser/86d86849c94045e321482e95af59d89a/execroot/mymonorepo/bazel-out/k8-fastbuild/bin/src/applications/myapp/myapp.runfiles/deps_python/pypi__aiomysql/aiomysql/connection.py", line 782, in _request_authentication
data += struct.pack('B', len(connect_attrs)) + connect_attrs
struct.error: ubyte format requires 0 <= number <= 255
...
raise OperationalError(2003,
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '10.5.3.133'")
This happens because it tries to create a packet to be sent over the network with 256 bytes, but the big name of the program overflows that size.
aiomysql/aiomysql/connection.py
Lines 186 to 189 in 0a8af23
aiomysql/aiomysql/connection.py
Lines 778 to 782 in 0a8af23
The simplest solution would be to remove the path (or part of it) from the network packet. However, I don't know if this can cause any unexpected problems. As far as I've tested, it didn't cause any errors
I wonder if I can make a Pull Request that fixes this, leaving only the path
after the last slash. Ex: from /home/myuser/.cache/bazel/_bazel_myuser/86d86849c94045e321482e95af59d89a/execroot/mymonorepo/bazel-out/k8-fastbuild/bin/src/applications/myapp/myapp.runfiles/mymonorepo/src/applications/myapp/src/server.py
to server.py
. This would solve my problem and that of some other people I saw while researching this error.