Skip to content

Commit f7bf348

Browse files
authored
fix: ensure IPC file closed after use (#15194)
## Description We fix a problem that caused IPC string files to evade proper context management, leading to spurious ``ResourceWarning``s at runtime. Fixes #15176.
1 parent 8217217 commit f7bf348

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ddtrace/internal/ipc.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from contextlib import contextmanager
21
import os
32
import secrets
43
import tempfile
@@ -57,9 +56,7 @@ class ReadLock(BaseUnixLock):
5756
class WriteLock(BaseUnixLock):
5857
__acquire_mode__ = fcntl.LOCK_EX
5958

60-
@contextmanager
61-
def open_file(path, mode):
62-
yield unpatched_open(path, mode)
59+
open_file = unpatched_open
6360

6461
except ModuleNotFoundError:
6562
# Availability: Windows
@@ -78,7 +75,7 @@ def release(self):
7875

7976
ReadLock = WriteLock = BaseWinLock # type: ignore
8077

81-
def open_file(path, mode):
78+
def open_file(path, mode): # type: ignore
8279
import _winapi
8380

8481
# force all modes to be read/write binary
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
Prevent a potential ``ResourceWarning`` in multiprocess scenarios.

0 commit comments

Comments
 (0)