Return pybind11::object* instead of pybind11::object Returning pybind11::object would cause reference count increasing but without GIL, reference count in Python may not be safe
| 109 | // Returning pybind11::object would cause reference count increasing |
| 110 | // but without GIL, reference count in Python may not be safe |
| 111 | py::object *PythonCallableRegistrar::Get(uint64_t unique_id) { |
| 112 | PADDLE_ENFORCE_NE( |
| 113 | python_callable_registry_.find(unique_id), |
| 114 | python_callable_registry_.end(), |
| 115 | common::errors::InvalidArgument( |
| 116 | "Unique_id %d is not found in python_callable_registry_. The " |
| 117 | "possible " |
| 118 | "reasons are below:\n" |
| 119 | "1. The python callable was not registered for `unique_id` by " |
| 120 | "`PythonCallableRegistrar::Register`\n" |
| 121 | "2. The python callable was remove from python_callable_registry_", |
| 122 | unique_id)); |
| 123 | return &(python_callable_registry_[unique_id]); |
| 124 | } |
| 125 | |
| 126 | } // namespace pybind |
| 127 | } // namespace paddle |
no test coverage detected