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

Attempting to connect results in SystemError('_PyEval_EvalFrameDefault returned NULL without setting an exception') #754

Open
ConorHartin opened this issue Oct 3, 2023 · 8 comments
Labels
Status: More info needed More information needed from issue author

Comments

@ConorHartin
Copy link

ConorHartin commented Oct 3, 2023

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.

@github-actions github-actions bot added the Status: Available No one has claimed responsibility for resolving this issue. label Oct 3, 2023
@gdt
Copy link

gdt commented Oct 4, 2023

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...)

@ConorHartin
Copy link
Author

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.

@ConorHartin
Copy link
Author

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

@gdt
Copy link

gdt commented Oct 4, 2023

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.

@ConorHartin
Copy link
Author

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

@gdt
Copy link

gdt commented Oct 6, 2023

I'm out of ideas -- but as I said, I have chosen to avoid understanding Windows....

@ConorHartin
Copy link
Author

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.

@PierreF
Copy link
Contributor

PierreF commented Jan 7, 2024

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.

@PierreF PierreF added Status: More info needed More information needed from issue author and removed Status: Available No one has claimed responsibility for resolving this issue. labels Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: More info needed More information needed from issue author
Projects
None yet
Development

No branches or pull requests

3 participants