-
Notifications
You must be signed in to change notification settings - Fork 727
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
AttributeError: 'NoneType' object has no attribute 'recv' #505
Comments
I have the same error. |
Hello, I'm facing the same issue and could reproduce quite easily/often. Using I think this issue is coming from the fact that the MainThread destroys the But at the same time, |
Hello any update? |
I am also having the same issue, it seems related to this case: #345 |
I fixed the problem by switching to use |
@russell-sealand its work not working, still get this error sometimes. |
@lucasjinreal please can you provide more information, for example, under what conditions do you get this error? I am unable to investigate without further information since this now works for me. |
I was having this issue too. The exception is in I was able to find a "hack" fix for this by setting the _thread attribute of the client to the current thread before calling loop_forever:
This ensures that we do not call |
With the sample code from #505 (comment) I'm able to reproduce the issue. In that code sample, the issue is in stop() function we call publish() which only submit a packet (it don't yet send it) and we disconnect just after. This means two threads will concurrently run, the one trying to actually send the publish packet and the one doing the disconnection. That being said, since disconnect() do an immediate disconnection, it will means your last publish could be lost. A fix for both the last publish that could be lost and the _sock that could be None could be:
As @jelbin313 there is indeed some assumption in the library that (at least some) function are only called from the loop thread (loop_forever, loop_start...). Their seems to have a bit better handling when the loop thread is one from loop_start(). A review of concurrency access / adding some locks should probably be done, but this is a large amount of work. As side node, disconnect() could be called from the thread doing the loop_forever (depending on application needs), if it's done from a callback like on_message, on_publish... But this really depends on application needs, not all application might be able to disconnect on this condition. |
The text was updated successfully, but these errors were encountered: