thds.mops 3.9.20250818180912__py3-none-any.whl → 3.9.20250821162253__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- thds/mops/pure/core/lock/types.py +1 -0
- thds/mops/pure/core/lock/write.py +43 -6
- {thds_mops-3.9.20250818180912.dist-info → thds_mops-3.9.20250821162253.dist-info}/METADATA +1 -1
- {thds_mops-3.9.20250818180912.dist-info → thds_mops-3.9.20250821162253.dist-info}/RECORD +7 -7
- {thds_mops-3.9.20250818180912.dist-info → thds_mops-3.9.20250821162253.dist-info}/WHEEL +0 -0
- {thds_mops-3.9.20250818180912.dist-info → thds_mops-3.9.20250821162253.dist-info}/entry_points.txt +0 -0
- {thds_mops-3.9.20250818180912.dist-info → thds_mops-3.9.20250821162253.dist-info}/top_level.txt +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import sys
|
|
3
|
+
import threading
|
|
2
4
|
import typing as ty
|
|
3
5
|
from dataclasses import dataclass
|
|
4
6
|
from datetime import datetime, timedelta
|
|
5
7
|
|
|
6
|
-
from thds.core import hostname, log
|
|
8
|
+
from thds.core import hostname, log, thread_debug
|
|
7
9
|
|
|
8
10
|
from . import _funcs
|
|
9
11
|
from .types import LockContents
|
|
@@ -37,12 +39,32 @@ class LockEmitter:
|
|
|
37
39
|
"write_count": self.write_count,
|
|
38
40
|
"hostname": hostname.friendly(),
|
|
39
41
|
"pid": str(os.getpid()),
|
|
42
|
+
"tid": threading.get_ident(),
|
|
40
43
|
"first_written_at": self.first_written_at,
|
|
41
44
|
"first_acquired_at": first_acquired_at.isoformat() if first_acquired_at else "",
|
|
42
45
|
"released_at": "",
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
|
|
49
|
+
def _pid_tid() -> str:
|
|
50
|
+
return f"{os.getpid()}-{threading.get_ident()}"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _capture_thread_info() -> dict[str, ty.Any]:
|
|
54
|
+
return dict(
|
|
55
|
+
ppid=os.getppid(),
|
|
56
|
+
process_cmd=[" ".join(sys.argv)],
|
|
57
|
+
**thread_debug.capture_thread_context(),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class _Debug:
|
|
62
|
+
def __init__(self) -> None:
|
|
63
|
+
self.original_pid = os.getpid()
|
|
64
|
+
self.original_thread_id = threading.get_ident()
|
|
65
|
+
self.thread_info: dict[str, dict] = {_pid_tid(): _capture_thread_info()}
|
|
66
|
+
|
|
67
|
+
|
|
46
68
|
class LockfileWriter:
|
|
47
69
|
"""The core purpose of this class is to allow setting of first_acquired_at immediately
|
|
48
70
|
after the first time that it is confirmed that we have acquired the lock.
|
|
@@ -65,7 +87,7 @@ class LockfileWriter:
|
|
|
65
87
|
self.blob_store, self.lock_uri = _funcs.store_and_lock_uri(lock_dir_uri)
|
|
66
88
|
self.generate_lock = generate_lock
|
|
67
89
|
self.expire_s = expire_s
|
|
68
|
-
self.debug = debug
|
|
90
|
+
self.debug = _Debug() if debug else None
|
|
69
91
|
self.writer_name = writer_name
|
|
70
92
|
self.first_acquired_at: ty.Optional[datetime] = None
|
|
71
93
|
|
|
@@ -115,21 +137,36 @@ class LockfileWriter:
|
|
|
115
137
|
# 'successful' write, it will not impose extra latency during the
|
|
116
138
|
# latency-critical section.
|
|
117
139
|
if self.debug and self.first_acquired_at:
|
|
118
|
-
|
|
140
|
+
pid = lock_contents["pid"]
|
|
141
|
+
tid = lock_contents["tid"]
|
|
142
|
+
pid_tid = f"{pid}-{tid}"
|
|
143
|
+
if pid_tid not in self.debug.thread_info:
|
|
144
|
+
self.debug.thread_info[pid_tid] = _capture_thread_info()
|
|
145
|
+
|
|
146
|
+
name = (";_name=" + self.writer_name) if self.writer_name else ""
|
|
119
147
|
first_written_at = lock_contents["first_written_at"]
|
|
120
148
|
hostname = lock_contents["hostname"]
|
|
121
|
-
|
|
149
|
+
|
|
122
150
|
acq_uuid = lock_contents["writer_id"]
|
|
123
151
|
assert "/" not in acq_uuid, lock_contents
|
|
124
152
|
debug_uri = self.blob_store.join(
|
|
125
153
|
self.lock_dir_uri,
|
|
126
154
|
"writers-debug",
|
|
127
|
-
f"firstwrite={first_written_at};_uuid={acq_uuid};_host={hostname};_pid={pid}{name}.json",
|
|
155
|
+
f"firstwrite={first_written_at};_uuid={acq_uuid};_host={hostname};_pid={pid};_tid={tid}{name}.json",
|
|
128
156
|
)
|
|
129
157
|
try:
|
|
130
158
|
self.blob_store.putbytes(
|
|
131
159
|
debug_uri,
|
|
132
|
-
_funcs.json_dumpb(
|
|
160
|
+
_funcs.json_dumpb(
|
|
161
|
+
dict(
|
|
162
|
+
lock_contents,
|
|
163
|
+
thread_debug=dict(
|
|
164
|
+
original_pid=self.debug.original_pid,
|
|
165
|
+
original_thread_id=self.debug.original_thread_id,
|
|
166
|
+
thread_info=self.debug.thread_info,
|
|
167
|
+
),
|
|
168
|
+
)
|
|
169
|
+
),
|
|
133
170
|
type_hint="application/mops-lock-breadcrumb",
|
|
134
171
|
)
|
|
135
172
|
except Exception:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: thds.mops
|
|
3
|
-
Version: 3.9.
|
|
3
|
+
Version: 3.9.20250821162253
|
|
4
4
|
Summary: ML Ops tools for Trilliant Health
|
|
5
5
|
Author-email: Trilliant Health <info@trillianthealth.com>
|
|
6
6
|
Project-URL: Repository, https://github.com/TrilliantHealth/ds-monorepo
|
|
@@ -72,8 +72,8 @@ thds/mops/pure/core/lock/_funcs.py,sha256=j4g8yVWnrAMPDKqLlq8nTnccM1KHSJ3g71L1iW
|
|
|
72
72
|
thds/mops/pure/core/lock/cli.py,sha256=uidtmgHB2y5LDkj7SQTncy_cNe1EfIseuiJPV9kcxBU,2488
|
|
73
73
|
thds/mops/pure/core/lock/maintain.py,sha256=UFhXdr9Q6FdPgq3PtELiAKdlRVl1sqF8IzAf3Oun4g4,9718
|
|
74
74
|
thds/mops/pure/core/lock/read.py,sha256=Ct5eYMlkTlEaV5Yhw6HWsDD7VrgdhDZoI6AVIQ0ts-4,1255
|
|
75
|
-
thds/mops/pure/core/lock/types.py,sha256=
|
|
76
|
-
thds/mops/pure/core/lock/write.py,sha256=
|
|
75
|
+
thds/mops/pure/core/lock/types.py,sha256=EiD3G5FODZnhNDvH_2pcyKuVOdz_gsrYSLiAv8grh1c,1006
|
|
76
|
+
thds/mops/pure/core/lock/write.py,sha256=wJByqa2edVhVcyrCaigWChVW3dYsoPBVt0HXyul-WpQ,6782
|
|
77
77
|
thds/mops/pure/core/memo/__init__.py,sha256=k64vX3XazDkP0m8MZgwqt0BV4vXg-ojK1EDhymucnuo,286
|
|
78
78
|
thds/mops/pure/core/memo/calls.py,sha256=kvm6kn-CbOLxZuo86BvzEJw69p7VlEJ8_mCiWd6uz-g,3631
|
|
79
79
|
thds/mops/pure/core/memo/function_memospace.py,sha256=PlQCs7dZ2Fu3gIjfzJMeOy7R5zPqYQDBp7OuViLqrpc,11644
|
|
@@ -109,8 +109,8 @@ thds/mops/pure/tools/summarize/cli.py,sha256=7kDtn24ok8oBO3jFjlMmOK3jnZYpMoE_5Y8
|
|
|
109
109
|
thds/mops/pure/tools/summarize/run_summary.py,sha256=w45qiQr7elrHDiK9Hgs85gtU3gwLuXa447ih1Y23BBY,5776
|
|
110
110
|
thds/mops/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
111
111
|
thds/mops/testing/deferred_imports.py,sha256=f0ezCgQAtzTqW1yAOb0OWgsB9ZrlztLB894LtpWDaVw,3780
|
|
112
|
-
thds_mops-3.9.
|
|
113
|
-
thds_mops-3.9.
|
|
114
|
-
thds_mops-3.9.
|
|
115
|
-
thds_mops-3.9.
|
|
116
|
-
thds_mops-3.9.
|
|
112
|
+
thds_mops-3.9.20250821162253.dist-info/METADATA,sha256=lE6NhLqX55KADAf8V4TBU1gwzby_wSv4JAGptd6-cS8,2225
|
|
113
|
+
thds_mops-3.9.20250821162253.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
114
|
+
thds_mops-3.9.20250821162253.dist-info/entry_points.txt,sha256=qKvCAaB80syXfxVR3xx6x9J0YJdaQWkIbVSw-NwFgMw,322
|
|
115
|
+
thds_mops-3.9.20250821162253.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
|
|
116
|
+
thds_mops-3.9.20250821162253.dist-info/RECORD,,
|
|
File without changes
|
{thds_mops-3.9.20250818180912.dist-info → thds_mops-3.9.20250821162253.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{thds_mops-3.9.20250818180912.dist-info → thds_mops-3.9.20250821162253.dist-info}/top_level.txt
RENAMED
|
File without changes
|