pylessard / python-udsoncan

Python implementation of UDS (ISO-14229) standard.
MIT License
564 stars 195 forks source link

SocketConnection cannot be closed #228

Closed nada-ben-ali closed 1 week ago

nada-ben-ali commented 3 months ago

Closing SocketConnection stucks on self.rxthread.join().

sock: image connector = SocketConnection(sock=sock)

It looks like this issue but for SocketConnection and not IsoTPSocketConnection (for IsoTPSocketConnection there is no stuck) using release 1.22.1 and reproducible with 1.23.0 as well.

By putting the self.sock.settimeout(0.1) back into the SocketConnection constructor, the problem was solved. It was removed when the selector was added in this MR.

pylessard commented 3 months ago

There is a unit test that checks that this work. Can you show me how you trigger that issue?

pylessard commented 3 months ago

Is it possible that you call open and close one after the other without waiting? I think there's a weakness in that case

Try to reproduce your error and then try this branch : fix_socket_connection_that_blocks_on_open_close

let me know the outcome

nada-ben-ali commented 3 months ago

Problem trigger:

I've tested your branch and the same problem still occurs. When opening the connection, self.started_event.is_set() was not True, so it closes the connection and then stucks in self.rxthread.join().

image
pylessard commented 3 months ago

Something does not make sense, You say that the the thread never starts but you are able to send and receive.

Are you able to write a demo script that recreate the issue and share that with me? I just don't see how this can happen...

nada-ben-ali commented 3 months ago

The thread never starts using the branch you provided with which I was unable to send or receive, it just gets stuck when opening the connection. But without the branch, I'm able to send and receive, but when I close the connection, it stucks.

I will try to make a small script.

pylessard commented 1 month ago

Following up on this, update? I still never reproduced your issue. Would need some kind of code that reproduce.

pylessard commented 2 weeks ago

If no update, I will close this issue