Skip to content

Commit a7d9cb8

Browse files
committed
Move Stub::DestroyPythonObjects call into Stub::DestroyInstance
1 parent 59cbe6d commit a7d9cb8

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/pb_stub.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,11 @@ Stub::GetOrCreateInstance()
10881088
void
10891089
Stub::DestroyInstance()
10901090
{
1091+
if (!stub_instance) {
1092+
return;
1093+
}
1094+
1095+
stub_instance->DestroyPythonObjects();
10911096
stub_instance.reset();
10921097
}
10931098

@@ -2197,7 +2202,6 @@ main(int argc, char** argv)
21972202
non_graceful_exit = true;
21982203

21992204
// Destroy stub and exit.
2200-
stub->DestroyPythonObjects();
22012205
logger.reset();
22022206
Stub::DestroyInstance();
22032207
exit(1);
@@ -2231,7 +2235,6 @@ main(int argc, char** argv)
22312235
// objects. If the scoped_interpreter is destroyed before the stub object,
22322236
// this process will no longer hold the GIL lock and destruction of the stub
22332237
// will result in segfault.
2234-
stub->DestroyPythonObjects();
22352238
logger.reset();
22362239
Stub::DestroyInstance();
22372240

src/pb_stub.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class Stub {
269269

270270
/// Cleans up Python objects and must be called before the destructor.
271271
/// This prevents problems that occur when Python object destructors
272-
/// call Stub::GetOrCreate.
272+
/// call Stub::GetOrCreateInstance.
273273
void DestroyPythonObjects();
274274

275275
/// Calls the user's is_ready() Python method and returns its response

0 commit comments

Comments
 (0)