-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for gc being invoked in a thread finalizer (#365)
* PR replicates issue #362, and will trigger a pybind11 internal error using an un-patched version of pybind11 * Only run IWYU on files changed in PR Note: * This bug requires the code in question to be run in a thread created by C++. fixes #362 Authors: - David Gardner (https://github.com/dagardner-nv) Approvers: - Michael Demoret (https://github.com/mdemoret-nv) URL: #365
- Loading branch information
1 parent
079e371
commit 8b20469
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import threading | ||
|
||
import mrc | ||
from mrc.tests.utils import RequireGilInDestructor | ||
|
||
TLS = threading.local() | ||
|
||
|
||
def test_gil_thread_local_storage(): | ||
""" | ||
Test to reproduce issue #362 | ||
No asserts needed if it doesn't segfault, then we're good | ||
""" | ||
|
||
def source_gen(): | ||
x = RequireGilInDestructor() | ||
TLS.x = x | ||
yield x | ||
|
||
def init_seg(builder: mrc.Builder): | ||
builder.make_source("souce_gen", source_gen) | ||
|
||
pipe = mrc.Pipeline() | ||
pipe.make_segment("seg1", init_seg) | ||
|
||
options = mrc.Options() | ||
executor = mrc.Executor(options) | ||
executor.register_pipeline(pipe) | ||
executor.start() | ||
executor.join() |