Skip to content

Commit 1393d6e

Browse files
authored
Release GIL during cancellation check (#372)
1 parent 2203a5b commit 1393d6e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pb_cancel.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// Copyright 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Redistribution and use in source and binary forms, with or without
44
// modification, are permitted provided that the following conditions
@@ -57,6 +57,9 @@ PbCancel::ShmPayload()
5757
bool
5858
PbCancel::IsCancelled()
5959
{
60+
// Release the GIL. Python objects are not accessed during the check.
61+
py::gil_scoped_release gil_release;
62+
6063
std::unique_lock<std::mutex> lk(mu_);
6164
// The cancelled flag can only move from false to true, not the other way, so
6265
// it is checked on each query until cancelled and then implicitly cached.

0 commit comments

Comments
 (0)