Attempting to connect results in SystemError('_PyEval_EvalFrameDefault returned NULL without setting an exception')
I have two separate projects that I want to communicate using MQTT. I can start up one of them and have it connect a Paho MQTT client without errors, and even communicate with it on the command line. After that, when I try to call client.connect in the other repo, it results in the error shown above. There are sometimes when it doesn't fail on that, but then fails with the same message when attempting to subscribe to a topic. The version of paho I'm using is 1.6.1.
The specific line triggering the exception is line 649 of client.py, at the top of the function _sock_send: return self._sock.send(buf) If I put a debug breakpoint there can run "self._sock.send(buf)" in a console, it can return a value of 14 without problems, but then immediately afterward when I try to step into or over that line, the exception occurs.
This seems like a host system python issue, and the internet says this is mysterious in general. You didn't explain what OS/version, what version of python, or post the full backtrace. Without that, I don't expect that anyone will be able to help you. (And if it is windows or non-current python, I won't be able to help...)
This seems like a host system python issue, and the internet says this is mysterious in general. You didn't explain what OS/version, what version of python, or post the full backtrace. Without that, I don't expect that anyone will be able to help you. (And if it is windows or non-current python, I won't be able to help...)
It is indeed Windows. The version of Python is 3.10.
Here is the traceback: Traceback (most recent call last): File "C:\Users<MyName><MyProjectFolder><my-project>\controllers\polling.py", line 432, in EthernetAdapter client.connect(other_repo_name if ENV == "production" else "localhost", 1883, 60), File "C:\Users<MyName>\AppData\Local\pypoetry\Cache\virtualenvs\api-ZOmfCtpL-py3.10\lib\site-packages\paho\mqtt\client.py", line 914, in connect return self.reconnect() File "C:\Users<MyName>\AppData\Local\pypoetry\Cache\virtualenvs\api-ZOmfCtpL-py3.10\lib\site-packages\paho\mqtt\client.py", line 1088, in reconnect return self._send_connect(self._keepalive) File "C:\Users<MyName>\AppData\Local\pypoetry\Cache\virtualenvs\api-ZOmfCtpL-py3.10\lib\site-packages\paho\mqtt\client.py", line 2819, in _send_connect return self._packet_queue(command, packet, 0, 0) File "C:\Users<MyName>\AppData\Local\pypoetry\Cache\virtualenvs\api-ZOmfCtpL-py3.10\lib\site-packages\paho\mqtt\client.py", line 3016, in _packet_queue return self.loop_write() File "C:\Users<MyName>\AppData\Local\pypoetry\Cache\virtualenvs\api-ZOmfCtpL-py3.10\lib\site-packages\paho\mqtt\client.py", line 1577, in loop_write rc = self._packet_write() SystemError: _PyEval_EvalFrameDefault returned NULL without setting an exception
I don't know what to make of that. It could be a python bug. You might try installing 3.11 and starting out with a fresh venv.
I don't know what to make of that. It could be a python bug. You might try installing 3.11 and starting out with a fresh venv.
I tried that and got the error described here, for which the recommended solution is... downgrade the version of Python: https://stackoverflow.com/questions/64427613/error-loading-psycopg2-module-dll-load-failed-while-importing-psycopg-the-spe
I'm out of ideas -- but as I said, I have chosen to avoid understanding Windows....
It seemed to pop up in debug mode, but only in one out of 2 different repos calling the same function with the exact same arguments. Disabling breakpoints prior to connecting/subscribing seemed to fix it for the one that was failing.
Do you have more details on when that happen ? It's Windows with Python 3.10.N ? Are you using SSL connection ? Websocket ? This only happen while debugging is enabled, which debugger ?
This seems more a Python/Debugger issue than paho bug. I don't think pure-Python code could be the cause of such error, I believe it require at least writing C extension.