Skip to content

Commit

Permalink
Release GIL during cancellation check (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
kthui authored Aug 7, 2024
1 parent 2203a5b commit 1393d6e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pb_cancel.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -57,6 +57,9 @@ PbCancel::ShmPayload()
bool
PbCancel::IsCancelled()
{
// Release the GIL. Python objects are not accessed during the check.
py::gil_scoped_release gil_release;

std::unique_lock<std::mutex> lk(mu_);
// The cancelled flag can only move from false to true, not the other way, so
// it is checked on each query until cancelled and then implicitly cached.
Expand Down

0 comments on commit 1393d6e

Please sign in to comment.