tickertape 0.5.1__tar.gz
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.
- tickertape-0.5.1/Cargo.toml +39 -0
- tickertape-0.5.1/LICENSE-APACHE +202 -0
- tickertape-0.5.1/LICENSE-MIT +21 -0
- tickertape-0.5.1/PKG-INFO +240 -0
- tickertape-0.5.1/README.md +209 -0
- tickertape-0.5.1/bindings/python/.gitignore +7 -0
- tickertape-0.5.1/bindings/python/Cargo.lock +237 -0
- tickertape-0.5.1/bindings/python/Cargo.toml +37 -0
- tickertape-0.5.1/bindings/python/LICENSE-APACHE +202 -0
- tickertape-0.5.1/bindings/python/LICENSE-MIT +21 -0
- tickertape-0.5.1/bindings/python/README.md +209 -0
- tickertape-0.5.1/bindings/python/examples/end_to_end.py +108 -0
- tickertape-0.5.1/bindings/python/src/config.rs +351 -0
- tickertape-0.5.1/bindings/python/src/errors.rs +471 -0
- tickertape-0.5.1/bindings/python/src/inspect.rs +70 -0
- tickertape-0.5.1/bindings/python/src/lib.rs +53 -0
- tickertape-0.5.1/bindings/python/src/owner.rs +311 -0
- tickertape-0.5.1/bindings/python/src/reader.rs +1449 -0
- tickertape-0.5.1/bindings/python/src/reports.rs +250 -0
- tickertape-0.5.1/bindings/python/src/status.rs +422 -0
- tickertape-0.5.1/bindings/python/src/writer.rs +613 -0
- tickertape-0.5.1/bindings/python/tests/conftest.py +53 -0
- tickertape-0.5.1/bindings/python/tests/helpers.py +81 -0
- tickertape-0.5.1/bindings/python/tests/test_api.py +914 -0
- tickertape-0.5.1/bindings/python/tests/test_columns.py +173 -0
- tickertape-0.5.1/bindings/python/tests/test_cross_language.py +156 -0
- tickertape-0.5.1/bindings/python/tests/test_errors.py +363 -0
- tickertape-0.5.1/bindings/python/tests/test_example.py +17 -0
- tickertape-0.5.1/bindings/python/tests/test_processes.py +1180 -0
- tickertape-0.5.1/bindings/python/tests/test_status.py +106 -0
- tickertape-0.5.1/crates/tickertape/Cargo.toml +37 -0
- tickertape-0.5.1/crates/tickertape/LICENSE-APACHE +202 -0
- tickertape-0.5.1/crates/tickertape/LICENSE-MIT +21 -0
- tickertape-0.5.1/crates/tickertape/README.md +23 -0
- tickertape-0.5.1/crates/tickertape/examples/quickstart.rs +28 -0
- tickertape-0.5.1/crates/tickertape/proptest-regressions/format.txt +7 -0
- tickertape-0.5.1/crates/tickertape/src/affinity.rs +131 -0
- tickertape-0.5.1/crates/tickertape/src/checkpoint.rs +727 -0
- tickertape-0.5.1/crates/tickertape/src/clock.rs +24 -0
- tickertape-0.5.1/crates/tickertape/src/config.rs +304 -0
- tickertape-0.5.1/crates/tickertape/src/crc.rs +637 -0
- tickertape-0.5.1/crates/tickertape/src/error.rs +263 -0
- tickertape-0.5.1/crates/tickertape/src/fault.rs +402 -0
- tickertape-0.5.1/crates/tickertape/src/format.rs +2365 -0
- tickertape-0.5.1/crates/tickertape/src/inspect.rs +685 -0
- tickertape-0.5.1/crates/tickertape/src/journal.rs +476 -0
- tickertape-0.5.1/crates/tickertape/src/lib.rs +91 -0
- tickertape-0.5.1/crates/tickertape/src/mmap.rs +1867 -0
- tickertape-0.5.1/crates/tickertape/src/notify.rs +243 -0
- tickertape-0.5.1/crates/tickertape/src/prefault.rs +355 -0
- tickertape-0.5.1/crates/tickertape/src/protocol_model.rs +219 -0
- tickertape-0.5.1/crates/tickertape/src/reader.rs +1395 -0
- tickertape-0.5.1/crates/tickertape/src/record.rs +76 -0
- tickertape-0.5.1/crates/tickertape/src/retention.rs +661 -0
- tickertape-0.5.1/crates/tickertape/src/samples.rs +176 -0
- tickertape-0.5.1/crates/tickertape/src/status/beacon.rs +950 -0
- tickertape-0.5.1/crates/tickertape/src/status/tests.rs +2025 -0
- tickertape-0.5.1/crates/tickertape/src/status.rs +1812 -0
- tickertape-0.5.1/crates/tickertape/src/writeback.rs +334 -0
- tickertape-0.5.1/crates/tickertape/src/writer.rs +2955 -0
- tickertape-0.5.1/crates/tickertape/tests/fork.rs +87 -0
- tickertape-0.5.1/pyproject.toml +67 -0
- tickertape-0.5.1/python/tickertape/__init__.py +130 -0
- tickertape-0.5.1/python/tickertape/_columns.py +46 -0
- tickertape-0.5.1/python/tickertape/_errors.py +204 -0
- tickertape-0.5.1/python/tickertape/_inspect.py +158 -0
- tickertape-0.5.1/python/tickertape/_native.pyi +241 -0
- tickertape-0.5.1/python/tickertape/_status.py +206 -0
- tickertape-0.5.1/python/tickertape/py.typed +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
resolver = "3"
|
|
3
|
+
members = [
|
|
4
|
+
"crates/tickertape",
|
|
5
|
+
"crates/tickertape-cli",
|
|
6
|
+
"crates/tickertape-ffi",
|
|
7
|
+
"tests",
|
|
8
|
+
"benches",
|
|
9
|
+
"examples",
|
|
10
|
+
]
|
|
11
|
+
exclude = ["fuzz", "compare", "bindings/python", "integrations"]
|
|
12
|
+
|
|
13
|
+
[workspace.package]
|
|
14
|
+
version = "0.5.1"
|
|
15
|
+
edition = "2024"
|
|
16
|
+
# MSRV. CI checks it in the `msrv` job; bump it only with a CHANGELOG entry.
|
|
17
|
+
rust-version = "1.85"
|
|
18
|
+
license = "MIT OR Apache-2.0"
|
|
19
|
+
repository = "https://github.com/thomas0903/tickertape"
|
|
20
|
+
homepage = "https://github.com/thomas0903/tickertape"
|
|
21
|
+
authors = ["The tickertape contributors"]
|
|
22
|
+
|
|
23
|
+
[workspace.dependencies]
|
|
24
|
+
tickertape = { path = "crates/tickertape", version = "0.5.1" }
|
|
25
|
+
|
|
26
|
+
[workspace.lints.rust]
|
|
27
|
+
unsafe_op_in_unsafe_fn = "deny"
|
|
28
|
+
# `tickertape_test_panic_abort` is private to one test of the C ABI crate (crates/tickertape-ffi/src/lib.rs).
|
|
29
|
+
unexpected_cfgs = { level = "warn", check-cfg = [
|
|
30
|
+
"cfg(loom)",
|
|
31
|
+
"cfg(fuzzing)",
|
|
32
|
+
"cfg(tickertape_force_soft_crc)",
|
|
33
|
+
"cfg(tickertape_test_panic_abort)",
|
|
34
|
+
] }
|
|
35
|
+
missing_debug_implementations = "warn"
|
|
36
|
+
rust_2018_idioms = { level = "warn", priority = -1 }
|
|
37
|
+
|
|
38
|
+
[workspace.lints.clippy]
|
|
39
|
+
undocumented_unsafe_blocks = "deny"
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 The tickertape contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tickertape
|
|
3
|
+
Version: 0.5.1
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
7
|
+
Classifier: Operating System :: MacOS
|
|
8
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
12
|
+
Classifier: Programming Language :: Rust
|
|
13
|
+
Classifier: Topic :: Database
|
|
14
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
15
|
+
Classifier: Typing :: Typed
|
|
16
|
+
Requires-Dist: pytest>=8 ; extra == 'test'
|
|
17
|
+
Provides-Extra: test
|
|
18
|
+
License-File: LICENSE-MIT
|
|
19
|
+
License-File: LICENSE-APACHE
|
|
20
|
+
Summary: Python bindings for tickertape: a local append-only event journal on memory-mapped files, with live cross-process readers and replay
|
|
21
|
+
Keywords: journal,mmap,event-log,trading,ipc
|
|
22
|
+
Author: The tickertape contributors
|
|
23
|
+
License-Expression: MIT OR Apache-2.0
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
26
|
+
Project-URL: Changelog, https://github.com/thomas0903/tickertape/blob/main/CHANGELOG.md
|
|
27
|
+
Project-URL: Documentation, https://github.com/thomas0903/tickertape/blob/main/docs/python.md
|
|
28
|
+
Project-URL: Homepage, https://github.com/thomas0903/tickertape
|
|
29
|
+
Project-URL: Issues, https://github.com/thomas0903/tickertape/issues
|
|
30
|
+
|
|
31
|
+
# tickertape for Python
|
|
32
|
+
|
|
33
|
+
Python bindings for [tickertape](https://github.com/thomas0903/tickertape), a local, append-only event journal on
|
|
34
|
+
memory-mapped segment files. One writer process appends records; any number of readers, in the same or other
|
|
35
|
+
processes on the same host, follow the journal live or replay it from any sequence number. Records are opaque
|
|
36
|
+
payload bytes with a sequence number, a caller-defined schema id and two caller-supplied timestamps.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install tickertape
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Prebuilt wheels: Linux (manylinux and musllinux, x86-64 and aarch64) and macOS (x86-64 and Apple Silicon), one wheel
|
|
43
|
+
per platform for CPython 3.11 and newer. No runtime dependencies. Windows is not supported (neither is the journal).
|
|
44
|
+
|
|
45
|
+
## Write, follow, replay
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import time
|
|
49
|
+
import tickertape as tt
|
|
50
|
+
|
|
51
|
+
with tt.Writer("/tmp/journal") as writer:
|
|
52
|
+
seq = writer.append(b"hello", schema_id=1, local_ts_ns=time.time_ns())
|
|
53
|
+
seqs = writer.append_batch([b"a", b"b", b"c"], schema_id=[2, 2, 3]) # one call, returns range(1, 4)
|
|
54
|
+
writer.checkpoint() # durable, not only visible
|
|
55
|
+
|
|
56
|
+
with tt.Reader("/tmp/journal") as reader:
|
|
57
|
+
for record in reader: # the records committed so far; doesn't wait
|
|
58
|
+
print(record.seq, record.schema_id, record.payload)
|
|
59
|
+
reader.seek(2)
|
|
60
|
+
batch = reader.read_many(1000) # up to 1000 records, one call
|
|
61
|
+
live = reader.next(timeout=5.0) # waits for the writer (Ctrl-C works), None on timeout
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`iter(reader)` returns a new iterator over the records committed so far. It never waits, and once it stops it stays
|
|
65
|
+
exhausted; a later `for` loop over the reader starts a new iterator at the reader's current position. To follow the
|
|
66
|
+
writer, call `reader.next(timeout=...)` (default `None`: wait forever) or `read_many`/`read_batch` with a timeout.
|
|
67
|
+
The reader itself is not an iterator: `next(reader)` raises `TypeError`.
|
|
68
|
+
|
|
69
|
+
A complete example, with a live follower in a second process and a hand-off to pandas and DuckDB, is
|
|
70
|
+
[`examples/end_to_end.py`](https://github.com/thomas0903/tickertape/blob/main/bindings/python/examples/end_to_end.py).
|
|
71
|
+
|
|
72
|
+
## Visible versus durable
|
|
73
|
+
|
|
74
|
+
A record is **visible** to readers, and survives the writer process dying, as soon as `append` returns. It is
|
|
75
|
+
**durable** (survives power loss, under the storage assumptions in the
|
|
76
|
+
[crash contract](https://github.com/thomas0903/tickertape/blob/main/docs/crash-contract.md)) only after a later
|
|
77
|
+
`checkpoint()` returns. Closing a writer does not checkpoint. Readers that must never act on a record a power loss
|
|
78
|
+
could erase use `Reader(path, durable_only=True)`, which returns only records covered by the last checkpoint.
|
|
79
|
+
|
|
80
|
+
`request_checkpoint()` starts the same checkpoint on a thread of the library and returns at once with the sequence
|
|
81
|
+
number it covers up to, so appends go on while it syncs; `checkpoint_progress()` returns a `CheckpointProgress`
|
|
82
|
+
(`durable`: the last durable `Checkpoint` or `None`; `pending`: the frontier still in flight or `None`). One runs at a
|
|
83
|
+
time; a request made while one runs waits for it, and later requests join it. `checkpoint()` and `close()` wait for
|
|
84
|
+
it. A background checkpoint that fails is raised once, by the next `request_checkpoint()`, `checkpoint_progress()`,
|
|
85
|
+
`checkpoint()` or `close()`, and poisons the writer like a failed `checkpoint()`. `close()` raises that error, or
|
|
86
|
+
`DurabilityLostError` if the writer was already poisoned (the writer is closed either way); leaving a `with` block
|
|
87
|
+
raises it too, unless the block raised. On Linux, `Writer(early_writeback=True)` (the default) starts the kernel's
|
|
88
|
+
write-back as the writer goes, so a checkpoint finds less to write, and `helper_cpus` (`"process"`, the default,
|
|
89
|
+
`"inherited"` or a list of CPU numbers) places the writer's helper threads; both do nothing on macOS.
|
|
90
|
+
|
|
91
|
+
A failed `checkpoint()` poisons the writer: later checkpoints raise `DurabilityLostError`, appends keep working. The
|
|
92
|
+
failure is not undone by reopening: records appended before a failed checkpoint may not be durable even if a writer
|
|
93
|
+
opened later in the same boot checkpoints successfully (on Linux a failed `fsync` can drop the dirty pages). Treat a
|
|
94
|
+
checkpoint error as an incident.
|
|
95
|
+
|
|
96
|
+
## Batches and columns
|
|
97
|
+
|
|
98
|
+
`append_batch(payloads, *, schema_id, venue_ts_ns, local_ts_ns)` takes an iterable of payloads (not a single `bytes`,
|
|
99
|
+
`bytearray`, `memoryview` or other bytes-like object, and not a `str`: those raise `TypeError`). Each metadata
|
|
100
|
+
argument is one int for all records or an iterable with exactly one per record. All arguments are converted and
|
|
101
|
+
their lengths checked before anything is appended, so a bad argument appends nothing. A record can still fail during
|
|
102
|
+
the append, for example one that doesn't fit in a segment (`RecordTooLargeError`) or a full disk
|
|
103
|
+
(`StorageFullError`). Then `append_batch` raises `BatchAppendError`: `payloads[:e.appended]` were appended (from
|
|
104
|
+
sequence number `e.first_seq`), the rest were not, and `e.__cause__` is the error.
|
|
105
|
+
|
|
106
|
+
To retry after resolving the cause, pass `payloads[e.failed_index:]` and slice every per-record metadata sequence at
|
|
107
|
+
the same index (`schema_id=schema_ids[e.failed_index:]`, ...); a single-int metadata value needs no slicing.
|
|
108
|
+
`append_batch` consumes its arguments, so if you may retry, pass lists, tuples or arrays, not one-shot iterators or
|
|
109
|
+
generators. An exception raised by an argument's iterator (including `KeyboardInterrupt`) propagates as it is, with
|
|
110
|
+
nothing appended. A closed writer, or one used in a forked child, raises before consuming any argument.
|
|
111
|
+
|
|
112
|
+
`read_many(max_records, *, timeout=0)` waits up to `timeout` seconds for the first record, then returns what is
|
|
113
|
+
already committed. `read_batch` does the same but returns a `RecordBatch` of columns: little-endian `bytes` for
|
|
114
|
+
`seq`, `schema_id`, `venue_ts_ns`, `local_ts_ns`, and Arrow-style payload offsets and data. A `RecordBatch` has a
|
|
115
|
+
length, can be indexed (`batch[i]`, `batch[-1]`) and iterated (each item a `Record`); slicing raises `TypeError` (use
|
|
116
|
+
`batch.records()[a:b]`, or slice the arrays from `to_numpy()`). As for a list, an index must be an int (or have
|
|
117
|
+
`__index__`): other types raise `TypeError`, and only an int out of range raises `IndexError`.
|
|
118
|
+
|
|
119
|
+
Timeouts are seconds as an int, a float or a `datetime.timedelta`. `None`, `math.inf` and any value too large to
|
|
120
|
+
represent (such as `sys.maxsize`) wait forever; negative values and NaN raise `ValueError`. The defaults differ on
|
|
121
|
+
purpose: `next()` waits forever, `read_many` and `read_batch` don't wait.
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
batch = reader.read_batch(100_000)
|
|
125
|
+
arrays = batch.to_numpy() # needs numpy; numeric columns share the batch's buffers
|
|
126
|
+
table = batch.to_arrow() # needs pyarrow; payload is large_binary
|
|
127
|
+
frame = batch.to_pandas() # needs pandas
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
NumPy, pyarrow and pandas are optional and imported only when these methods are called.
|
|
131
|
+
|
|
132
|
+
## Copies, lifetimes and threads
|
|
133
|
+
|
|
134
|
+
- Payloads are `bytes` or any buffer of unsigned bytes (`bytearray`, `memoryview`, `array('B')`, `uint8` NumPy
|
|
135
|
+
arrays); buffers of other item types (`array('b')`, `int8` or wider arrays) raise `TypeError`, view them as bytes
|
|
136
|
+
first (`memoryview(a).cast('B')`, `a.view(np.uint8)`). `append` uses a `bytes` payload without copying it and copies
|
|
137
|
+
other buffers once. The payload is then copied into the journal.
|
|
138
|
+
- Every `Record` owns its payload as an ordinary `bytes` object; it stays valid after the reader moves on or closes.
|
|
139
|
+
`RecordBatch` columns are `bytes` too; arrays made from them keep them alive.
|
|
140
|
+
- A reader copies records into a staging buffer before building a result. Once all staged records have been
|
|
141
|
+
delivered, it keeps at most 6 MiB (6,291,456 bytes) of that buffer for reuse (enough for `read_batch(10_000)` with
|
|
142
|
+
payloads of a few hundred bytes); a larger one is freed, with the GIL released, by the read that delivers the last
|
|
143
|
+
of them, before the call returns (or by a `seek`). Records that a read took from the journal but did not deliver,
|
|
144
|
+
because it raised (on a signal, for example), stay staged in their buffer, however large, until a later read
|
|
145
|
+
returns them.
|
|
146
|
+
- The reader is tickertape's safe `pread` reader, memory-safe whatever other processes do to the files. The
|
|
147
|
+
zero-copy mapped reader of the Rust library is not exposed to Python.
|
|
148
|
+
- Blocking calls (`next`, waiting `read_many`/`read_batch`, `checkpoint`, opening a writer, batch loops) release the
|
|
149
|
+
GIL.
|
|
150
|
+
- `Writer` and `Reader` objects can be used from any thread; calls on one object are serialized. A waiting read
|
|
151
|
+
holds its reader for at most 50 ms at a time, so other calls on that reader (`seek`, `close()`, another read) run
|
|
152
|
+
in between; `closed`, `position` and `repr` never wait at all. Reads from several threads share the one cursor:
|
|
153
|
+
each record goes to exactly one of them, in order, and which one gets it is unspecified. A read that does not wait
|
|
154
|
+
returns nothing only when no committed record is left, even if another thread took the records it had found.
|
|
155
|
+
Give each consumer its own reader. Changing the class of an argument (for example adding or removing its
|
|
156
|
+
`__iter__`) from another thread while a call is using that argument is not supported.
|
|
157
|
+
- `close()` from another thread (or from a signal handler) ends a read that is waiting on that reader within about
|
|
158
|
+
50 ms; the waiting call raises `ValueError`, also when its timeout has passed meanwhile.
|
|
159
|
+
- Fork: a `Writer` or `Reader` belongs to the process that opened it. In a child created by `fork()` (including
|
|
160
|
+
`multiprocessing`'s default start method on Linux before Python 3.14), every method raises `UsedAfterForkError`
|
|
161
|
+
without touching the journal. A handle is the child's own only if it was opened in the child; a process id that
|
|
162
|
+
matches is not enough (the bindings also count forks, so a reused process id is still recognised as foreign).
|
|
163
|
+
`close()`, leaving a `with` block and garbage collection in the child release the child's copies of the file
|
|
164
|
+
descriptors and memory mappings and nothing else: the parent keeps the writer's lock, and nothing is synced,
|
|
165
|
+
changed or removed. So once the parent closes its writer, the journal can be opened again while the child is
|
|
166
|
+
still running. Close inherited handles early in the child (until then its copy of the lock file's descriptor
|
|
167
|
+
keeps the journal locked after the parent closes it). A handle that another thread was using at the moment of the
|
|
168
|
+
fork is never released in the child: its state may be half-updated, and the dead thread's frame keeps a reference
|
|
169
|
+
to it anyway, so its descriptors (for a writer, including the lock) stay open until the child exits or calls
|
|
170
|
+
`exec`. A read that a signal handler interrupted to fork raises `UsedAfterForkError` in the child when the handler
|
|
171
|
+
returns, having consumed nothing (also if its timeout passed meanwhile or the handler closed the reader). More
|
|
172
|
+
generally, the owner check is the last thing the bindings do before they hand a result or an exception back to the
|
|
173
|
+
interpreter (an exception object is built before it): if Python code forks during a call (a signal handler, or a
|
|
174
|
+
finalizer run by the garbage collector), the call raises `UsedAfterForkError` in the child, whatever it would have
|
|
175
|
+
returned or raised. A fork that happens after that, while the interpreter delivers the result (stores it, adds a
|
|
176
|
+
traceback entry, or runs a signal handler), is after the call. That last check compares only the bindings' fork
|
|
177
|
+
count, which CPython's fork hooks advance (the full check, process id included, is made as each call starts): a
|
|
178
|
+
child forked during a call by C code that bypasses those hooks (a direct `fork()` that does not call
|
|
179
|
+
`PyOS_AfterFork_Child`, as CPython requires) is detected only when it next calls a method. Arguments are converted
|
|
180
|
+
before a method runs, so an invalid argument raises its `TypeError` (or `OverflowError`) in any process. Open
|
|
181
|
+
handles in the child after it starts, or use the `spawn` or `forkserver` start method.
|
|
182
|
+
- Free-threaded Python: no free-threaded wheels are published (abi3 wheels cannot load there). Building from the
|
|
183
|
+
sdist for 3.14t works and runs without the GIL, but it is not tested in CI.
|
|
184
|
+
|
|
185
|
+
### Ctrl-C and other signals
|
|
186
|
+
|
|
187
|
+
Waits check for signals at least every 50 ms, with the reader's lock released, so Ctrl-C raises `KeyboardInterrupt`
|
|
188
|
+
promptly and signal handlers may use the reader (even close it). For every read (`next`, `try_next`, `read_many`,
|
|
189
|
+
`read_batch`, iteration), in any thread:
|
|
190
|
+
|
|
191
|
+
- If it raises (a signal handler raised, the reader was closed, or anything else failed), it consumed nothing: the
|
|
192
|
+
records it had already taken from the journal stay with the reader and the next read returns them first, in order.
|
|
193
|
+
- If it returns a value, exactly the records in that value were consumed.
|
|
194
|
+
|
|
195
|
+
Python runs signal handlers only in the main thread, so what follows about handlers concerns reads in the main
|
|
196
|
+
thread. A read there delivers its records only after its result is complete and pending signal handlers have run.
|
|
197
|
+
That covers a signal that arrives while the read builds a large result, or while it waits for another thread that is
|
|
198
|
+
using the reader: the read runs the handlers immediately before every attempt to take the reader's lock, and nothing
|
|
199
|
+
can run or wait between its final signal check and the delivery. While other threads keep taking the reader's lock
|
|
200
|
+
(a stream of `seek` calls, for example), the delivery waits and the read may start over; it stays interruptible
|
|
201
|
+
throughout, because every attempt is preceded by a signal check.
|
|
202
|
+
|
|
203
|
+
The boundary is that final signal check, and no binding can remove it: a signal that arrives after it is handled when
|
|
204
|
+
the call returns, after the read has delivered its records (and freed a staging buffer too large to keep). If its
|
|
205
|
+
handler raises before Python stores the result, the returned value is lost. A program that must not lose a record on
|
|
206
|
+
Ctrl-C should handle `SIGINT` itself (for example, set a flag in the handler and stop after the current record).
|
|
207
|
+
|
|
208
|
+
A read in another thread never runs handlers, and a signal does not interrupt it; the two rules above still hold for
|
|
209
|
+
it. A handler that runs in the main thread meanwhile may use the reader: if it closes it, the other thread's read
|
|
210
|
+
raises `ValueError` and consumes nothing, or returns its records if it delivered them before the close took effect.
|
|
211
|
+
|
|
212
|
+
## Errors
|
|
213
|
+
|
|
214
|
+
All errors derive from `tt.TickertapeError`: `JournalIOError` (also an `OSError`) and `StorageFullError`,
|
|
215
|
+
`LockedError` (another writer has the journal), `CorruptJournalError` (`path`, `offset`, `reason` code, `details`),
|
|
216
|
+
`UnsupportedVersionError`, `JournalNotFoundError`, `SeqUnavailableError` (also a `LookupError`),
|
|
217
|
+
`RecordTooLargeError` and `InvalidConfigError` (also `ValueError`), `DurabilityLostError`, `SequenceExhaustedError`,
|
|
218
|
+
`DiscardedError` (call `seek` to continue), `BatchAppendError` and `UsedAfterForkError`. Using a closed object raises
|
|
219
|
+
`ValueError`. Every exception keeps its message and the current values of its attributes across `pickle` (for
|
|
220
|
+
example from a `multiprocessing` worker); `JournalIOError.strerror` is the OS message, as `os.strerror(errno)`.
|
|
221
|
+
|
|
222
|
+
`Writer.recovery_report` (a `RecoveryReport` with a list of `RecoveryAction`) and `Writer.retention_report` (a
|
|
223
|
+
`RetentionReport`) are named tuples, like the results of the inspection functions below.
|
|
224
|
+
|
|
225
|
+
## Inspection
|
|
226
|
+
|
|
227
|
+
`tt.verify(path)`, `tt.list_segments(path)` and `tt.read_checkpoint(path)` never take the writer lock and are safe
|
|
228
|
+
while a writer runs. So is `tt.JournalStatus.sample(path)`, the sample that `tickertape status` prints (head, checkpoint age,
|
|
229
|
+
exposure, storage headroom, reader beacons); `Writer.metrics()` and `Reader.metrics(status)` add what only the writer
|
|
230
|
+
knows and a reader's lag. Unknown values are `None`, never guesses.
|
|
231
|
+
|
|
232
|
+
## More
|
|
233
|
+
|
|
234
|
+
- Full Python guide, including the dependency-free read-only decoder that needs no install:
|
|
235
|
+
[`docs/python.md`](https://github.com/thomas0903/tickertape/blob/main/docs/python.md)
|
|
236
|
+
- Design decisions: [ADR 0029](https://github.com/thomas0903/tickertape/blob/main/docs/decisions/0029-python-bindings.md)
|
|
237
|
+
- Byte format: [`docs/format.md`](https://github.com/thomas0903/tickertape/blob/main/docs/format.md)
|
|
238
|
+
|
|
239
|
+
Licensed under MIT OR Apache-2.0.
|
|
240
|
+
|