https://code.visualstudio.com/docs/python/debugging#_troubleshooting
debugpy.debug_this_thread() はファイルの先頭ではなく、デバッグするthreadの先頭に置いておくようだ。
またこれが入っている場合にはVScodeで run -> Start debugging で実行する必要がある。run -> Run without debugging とすると
Could not connect to 127.0.0.1: 5678
ConnectionRefusedError: [Errno 111] Connection refused
というエラーとなってしまう。よってデバッグ無しで走らせるときには debugpy.debug_this_thread() このコードを外しておく必要がある。