Loading...
Searching...
No Matches
PyGuard.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#pragma once
13
14#include <pybind11/embed.h>
15
16namespace eonc {
17
18// Lazy, one-shot Python interpreter init. We intentionally never call
19// Py_Finalize so that pybind11 py::object members in potentials can release
20// their refcounts during normal destruction without racing against interpreter
21// teardown. The OS reclaims everything on process exit.
22inline void ensure_interpreter() {
23 if (!Py_IsInitialized()) {
24 pybind11::initialize_interpreter();
25 }
26}
27
28} // namespace eonc
RAII resource manager for the ARTn C library with global synchronization.
void ensure_interpreter()
Definition NbGuard.h:21