intelino-code / intelino-trainlib-py

Python library (SDK) for interacting with the intelino smart train.
Other
11 stars 4 forks source link

python3 -m intelino.scan crashes python in MacOS. The library works fine, otherwise. #3

Closed chronakis closed 2 years ago

chronakis commented 2 years ago

The verification step, python3 -m intelino.scan, crashes python. The good news is that the library works fine, otherwise.

This may be isolated to my hardware/software but it would be good to add a note to the documentation that it may happen. I have been stuck on it for about an hour before deciding to ignore it and, to my surprise, everything worked very well.

Please find the crash dump here, if it helps.

Thanks

petrusek commented 2 years ago

Thank you for the report (and your patience). A full Python crash is a very bad outcome, especially on a verification step, so we should try to fix it... before scaring people that it might happen :-) (IMHO it should never happen).

I've checked the crash dump, but there are not many clues on what could be causing it.

Does it also happen with python3 -m intelino.scan --info?

The code of the scan utility is here https://github.com/intelino-code/intelino-trainlib-async-py/blob/master/intelino/scan/__main__.py ... it is in our async repository (which is a dependency of this library). If you would find a moment to copy-paste the code and try locating where the crash happens it would be great.

My guess is, that it might be caused by some BLE device around which does not interact nicely with Python / Bleak... so when we list the other devices, we could maybe limit what to print (if it would help preventing the crash).

chronakis commented 2 years ago

I found the problem and the good news it is indeed something related with my environment.

Turns out the culprit is iTerm2 (build 3.14...). When running scan/__main__.py from Mac's own terminal utility or PyCharm, I am getting a dialogue asking me for permission to use bluetooth, the first time. The scanner works well and devices are listed. When I run this through iTerm, it just crashes. So this is likely an iTerm issue with the way it requests permissions.

I am not sure how popular iTerm is and if is worth adding a note in your documentation. I will definitely raise this with the iTerm's developers.

Many thanks!

Yiannis

PS: Feel free to close the issue.

petrusek commented 2 years ago

Perfect, thank you for the note. I'm glad you managed to find what was causing it.