| 778 | } |
| 779 | |
| 780 | bool start_debugpy(const int port) { |
| 781 | ensure_initialized(); |
| 782 | |
| 783 | auto& pm = PackageManager::instance(); |
| 784 | if (!pm.is_installed("debugpy")) { |
| 785 | LOG_INFO("Installing debugpy..."); |
| 786 | const auto result = pm.install("debugpy"); |
| 787 | if (!result.success) { |
| 788 | LOG_ERROR("Failed to install debugpy: {}", result.error); |
| 789 | return false; |
| 790 | } |
| 791 | update_python_path(); |
| 792 | } |
| 793 | |
| 794 | int rc; |
| 795 | { |
| 796 | const GilAcquire gil; |
| 797 | const std::string code = std::format("import debugpy; debugpy.listen(('0.0.0.0', {}))", port); |
| 798 | rc = PyRun_SimpleString(code.c_str()); |
| 799 | } |
| 800 | |
| 801 | if (rc != 0) { |
| 802 | LOG_ERROR("Failed to start debugpy on port {}", port); |
| 803 | return false; |
| 804 | } |
| 805 | |
| 806 | LOG_INFO("debugpy listening on port {}", port); |
| 807 | return true; |
| 808 | } |
| 809 | |
| 810 | void join_plugin_preload() { |
| 811 | if (g_plugin_preload_thread.thread.joinable()) { |
no test coverage detected