global-buffer 1.0.2__cp313-cp313-win_amd64.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.
@@ -0,0 +1,46 @@
1
+ """GlobalBuffer: cross-platform, cross-process shared-memory ring buffer.
2
+
3
+ Zero-copy numpy array streams and pydantic message streams, last-value or
4
+ in-order reads, and background callbacks. See the README for the full API.
5
+ """
6
+ from ._version import __version__
7
+ from .buffer import GlobalBuffer, open_shm, shm_name
8
+ from .consumer import Consumer
9
+ from .exceptions import (BufferClosed, BufferExists, BufferNotFound, Empty,
10
+ GlobalBufferError, SchemaMismatch)
11
+ from .reader import Reader
12
+ from .spec import ArraySpec
13
+
14
+
15
+ def create(name, schema, capacity, max_bytes=None):
16
+ """Create and own a named buffer (writer). ``schema`` is an
17
+ :class:`ArraySpec` or a ``pydantic.BaseModel`` subclass."""
18
+ return GlobalBuffer(name, schema, capacity, max_bytes=max_bytes)
19
+
20
+
21
+ def attach(name, model=None, poll_min=None, poll_max=None):
22
+ """Attach to an existing named buffer (reader). For message buffers, pass
23
+ ``model=`` to get validated instances and a schema-compatibility check.
24
+
25
+ ``poll_max`` raises the wakeup poll-backoff cap (seconds); a larger value
26
+ lowers idle CPU when running many readers, at the cost of up to that much
27
+ extra wake latency (default ~2 ms). ``poll_min`` sets the busy floor."""
28
+ return Reader(name, model=model, poll_min=poll_min, poll_max=poll_max)
29
+
30
+
31
+ def unlink(name):
32
+ """Remove a named segment by name (e.g. to clean up after a crash)."""
33
+ try:
34
+ shm = open_shm(shm_name(name))
35
+ except FileNotFoundError:
36
+ return
37
+ shm.close()
38
+ shm.unlink()
39
+
40
+
41
+ __all__ = [
42
+ "__version__", "ArraySpec", "GlobalBuffer", "Reader", "Consumer",
43
+ "create", "attach", "unlink",
44
+ "GlobalBufferError", "Empty", "SchemaMismatch", "BufferClosed",
45
+ "BufferExists", "BufferNotFound",
46
+ ]