| 250 | } |
| 251 | |
| 252 | void start_dev_python_watcher(PyObject* const lfs_plugins) { |
| 253 | if (!env_flag_enabled("LFS_PYTHON_HOT_RELOAD", true)) { |
| 254 | LOG_INFO("Python dev hot reload disabled by LFS_PYTHON_HOT_RELOAD"); |
| 255 | return; |
| 256 | } |
| 257 | if (!lfs_plugins) { |
| 258 | return; |
| 259 | } |
| 260 | |
| 261 | PyObject* const manager_cls = PyObject_GetAttrString(lfs_plugins, "PluginManager"); |
| 262 | if (!manager_cls) { |
| 263 | PyErr_Print(); |
| 264 | LOG_WARN("Python dev hot reload: lfs_plugins.PluginManager not found"); |
| 265 | return; |
| 266 | } |
| 267 | |
| 268 | PyObject* const manager = PyObject_CallMethod(manager_cls, "instance", nullptr); |
| 269 | Py_DECREF(manager_cls); |
| 270 | if (!manager) { |
| 271 | PyErr_Print(); |
| 272 | LOG_WARN("Python dev hot reload: failed to get PluginManager instance"); |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | PyObject* const result = PyObject_CallMethod(manager, "start_watcher", nullptr); |
| 277 | Py_DECREF(manager); |
| 278 | if (!result) { |
| 279 | PyErr_Print(); |
| 280 | LOG_WARN("Python dev hot reload: failed to start watcher"); |
| 281 | return; |
| 282 | } |
| 283 | |
| 284 | Py_DECREF(result); |
| 285 | LOG_INFO("Python dev hot reload watcher started"); |
| 286 | } |
| 287 | #endif |
| 288 | |
| 289 | std::string consume_python_error_detailed() { |
no test coverage detected