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