Mon Nov 23, 2020 2:16 pm
If it is hanging, neither printing "Jannis: in" or "Jannis: out", suspicion would have to fall on 'bluetooth.lookup_name' never returning.
What's your timeout value ? It's best to include full code as text rather than as a screen shot.
If it should be returning but it isn't, it's always hard to say why that would be. I have seen similar issues with 'urllib.urlopen' fetching web pages where that will simply hang forever. I can only guess that the libraries don't see something they are expecting and get jammed-up forever waiting for whatever it is which never happens. When the library code uses poorly written 'try-except' traps it's often not even possible to Ctrl-C out of the library code.
There may be some mileage in refactoring the code to use threading so you can check if a function has returned in a timely manner and, if not, terminate and restart the program or invoke a second function call and hope that works, that the code can keep running.
The problem there is terminating the program may not always work if a thread has hung, and invoking the same function in parallel might not work if the hung code is holding on to resources, and leaving hung code running in the background could eventually consume all available memory.
The proper course would be to dig down into the library code, identify where it is hanging, and find a way to prevent that. That will be easier where the hang is reproducible but will still require some effort.
Another option is to find a different library and hope that doesn't exhibit the same behaviour. Or use a different programming language. You could try using Python 3 and its libraries to see if that performs better.