| 311 | |
| 312 | template <typename Func> |
| 313 | void RunOnce(Func&& func) { |
| 314 | auto do_init = [&]() { |
| 315 | OwnedRef module; |
| 316 | if (ImportModule(module_name, &module).ok()) { |
| 317 | #ifndef Py_GIL_DISABLED |
| 318 | // Since ImportModule can release the GIL, another thread could have |
| 319 | // already initialized the static data. |
| 320 | if (initialized) { |
| 321 | return; |
| 322 | } |
| 323 | #endif |
| 324 | func(module); |
| 325 | } |
| 326 | }; |
| 327 | #ifdef Py_GIL_DISABLED |
| 328 | std::call_once(initialized, do_init); |
| 329 | #else |
| 330 | if (!initialized) { |
| 331 | do_init(); |
| 332 | initialized = true; |
| 333 | } |
| 334 | #endif |
| 335 | } |
| 336 | }; |
| 337 | |
| 338 | static PyObject* uuid_UUID = nullptr; |
no test coverage detected