_listening = False def debugger(): global _listening if not _listening: import debugpy debugpy.listen(5678) debugpy.wait_for_client() _listening = True