python-statemachine 3.1.0__py3-none-any.whl → 3.1.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-statemachine
3
- Version: 3.1.0
3
+ Version: 3.1.1
4
4
  Summary: Python Finite State Machines made easy.
5
5
  Project-URL: homepage, https://github.com/fgmacedo/python-statemachine
6
6
  Author-email: Fernando Macedo <fgmacedo@gmail.com>
@@ -1,6 +1,6 @@
1
- statemachine/__init__.py,sha256=ULem4I0OFrhvgXyaka9WLO8OJimg8LtFKKrfG1Zc7Rs,445
1
+ statemachine/__init__.py,sha256=6QmaIOvUXefWn7Ur1IFrqnM8ehtcwtnPrvRE44ELq4w,445
2
2
  statemachine/callbacks.py,sha256=mY_RAl86240vG2C94ij6AdD7CgsIM8mr0wvpSAMAPv0,14644
3
- statemachine/configuration.py,sha256=pt3Sq323bZKymnjQzLotqkNVkgqNHh3pmSIXLxk-obA,5453
3
+ statemachine/configuration.py,sha256=5tTx4-_cXnu6apxdvUfhfhDe6zym9BJynqQ-lrIxnls,6018
4
4
  statemachine/dispatcher.py,sha256=xvA1Kf1xGQivHTpaGm_HC22vqAmE_tTm9LQwyVLRWLE,7841
5
5
  statemachine/event.py,sha256=d_Ky5ph30Os305BceN4x-rftZH-h8G1U5ei34-66lnI,7669
6
6
  statemachine/event_data.py,sha256=7_hoE0cp-0uW71Kk3erO3eYM6anTT5X3slGMcehIGIo,3111
@@ -48,11 +48,11 @@ statemachine/io/scxml/invoke.py,sha256=raRStlMBOfxto6KIkCbi3jJ3UQ3QfuT0ezn4B48A6
48
48
  statemachine/io/scxml/parser.py,sha256=zggZwu0rHZNWDaJTHD2XC3MrCy_bi4CNHStfWE9NHgU,16582
49
49
  statemachine/io/scxml/processor.py,sha256=_hjW4VTuzbPK2q5a7dp2kYMBcbRBZFbjz-wJKSZLI8I,9467
50
50
  statemachine/io/scxml/schema.py,sha256=xNpW_nkS2Z_hye5p1WLr8VhuM85Nic2HqRLCnoFN3ss,3927
51
- statemachine/locale/en/LC_MESSAGES/statemachine.po,sha256=exLJzm2uGsLWbggRKvgLzqqBstusQWu38HC0IMxEI6g,5338
52
- statemachine/locale/hi_IN/LC_MESSAGES/statemachine.po,sha256=aAA-ZsZt0SWM5zykZMuaQQli0DWS-yKkMM7lnXHIF10,7948
53
- statemachine/locale/pt_BR/LC_MESSAGES/statemachine.po,sha256=4Gc2vilchzx1-zTmQqJgweFz_wHzEJBjUG4bgR0xlNI,5814
54
- statemachine/locale/zh_CN/LC_MESSAGES/statemachine.po,sha256=X51ghMEP9ZNda9HZO0hcYez4HdXuvi-0GXKay2S3ZIQ,5369
55
- python_statemachine-3.1.0.dist-info/METADATA,sha256=-Hi9lHdURp725XVA52Ew2j6PGKWN1xN2Y1caBTVtCYg,12249
56
- python_statemachine-3.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
57
- python_statemachine-3.1.0.dist-info/licenses/LICENSE,sha256=zcP7TsJMqaFxuTvLRZPT7nJl3_ppjxR9Z76BE9pL5zc,1074
58
- python_statemachine-3.1.0.dist-info/RECORD,,
51
+ statemachine/locale/en/LC_MESSAGES/statemachine.po,sha256=MZpydlIX__YjJZw2-zBEVNjuUqLEt6AYYWfrq8Rff90,5338
52
+ statemachine/locale/hi_IN/LC_MESSAGES/statemachine.po,sha256=LLaDkTU0GZaataEWl35ap1SDgsJkdEr-0_u8gg5q7kI,7948
53
+ statemachine/locale/pt_BR/LC_MESSAGES/statemachine.po,sha256=z-phNrS8soB26B67yz3f6eYB-KpcXX0MZEBWJqsztgg,5814
54
+ statemachine/locale/zh_CN/LC_MESSAGES/statemachine.po,sha256=nxhwoPj23VjI_4O3r3hKjoc3H5rGox7gbdY-wzWFm6A,5369
55
+ python_statemachine-3.1.1.dist-info/METADATA,sha256=EdRvT7EegYFkRrnnT5PR6yPD4oksBzb9112dPFO1a4w,12249
56
+ python_statemachine-3.1.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
57
+ python_statemachine-3.1.1.dist-info/licenses/LICENSE,sha256=zcP7TsJMqaFxuTvLRZPT7nJl3_ppjxR9Z76BE9pL5zc,1074
58
+ python_statemachine-3.1.1.dist-info/RECORD,,
statemachine/__init__.py CHANGED
@@ -8,7 +8,7 @@ from .statemachine import TModel
8
8
 
9
9
  __author__ = """Fernando Macedo"""
10
10
  __email__ = "fgmacedo@gmail.com"
11
- __version__ = "3.1.0"
11
+ __version__ = "3.1.1"
12
12
 
13
13
  __all__ = [
14
14
  "StateChart",
@@ -73,8 +73,13 @@ class Configuration:
73
73
  def states(self) -> "OrderedSet[State]":
74
74
  """The set of currently active :class:`State` instances (cached)."""
75
75
  raw = self.value
76
- if self._cached is not None and self._cached_value is raw:
77
- return self._cached
76
+ # Snapshot the cache fields locally another thread may call
77
+ # ``_invalidate()`` between the freshness check and the return,
78
+ # so reading ``self._cached`` twice would risk returning ``None``.
79
+ cached = self._cached
80
+ cached_value = self._cached_value
81
+ if cached is not None and cached_value is raw:
82
+ return cached
78
83
  if raw is None:
79
84
  return OrderedSet()
80
85
 
@@ -92,14 +97,17 @@ class Configuration:
92
97
  # -- Incremental mutation (used by the engine) -----------------------------
93
98
 
94
99
  def add(self, state: "State"):
95
- """Add *state* to the configuration."""
96
- values = self._read_from_model()
100
+ """Add *state* to the configuration (copy-on-write for thread safety)."""
101
+ # Copy so we never mutate the OrderedSet still held by concurrent
102
+ # readers or by the cache identity check. ``_read_from_model`` may
103
+ # return the same ref stored on the model.
104
+ values = OrderedSet(self._read_from_model())
97
105
  values.add(state.value)
98
106
  self._write_to_model(values)
99
107
 
100
108
  def discard(self, state: "State"):
101
- """Remove *state* from the configuration."""
102
- values = self._read_from_model()
109
+ """Remove *state* from the configuration (copy-on-write for thread safety)."""
110
+ values = OrderedSet(self._read_from_model())
103
111
  values.discard(state.value)
104
112
  self._write_to_model(values)
105
113
 
@@ -3,7 +3,7 @@
3
3
  #
4
4
  msgid ""
5
5
  msgstr ""
6
- "Project-Id-Version: 3.1.0\n"
6
+ "Project-Id-Version: 3.1.1\n"
7
7
  "Report-Msgid-Bugs-To: fgmacedo@gmail.com\n"
8
8
  "POT-Creation-Date: 2026-05-15 12:08-0300\n"
9
9
  "PO-Revision-Date: 2026-02-24 14:31-0300\n"
@@ -3,7 +3,7 @@
3
3
  #
4
4
  msgid ""
5
5
  msgstr ""
6
- "Project-Id-Version: 3.1.0\n"
6
+ "Project-Id-Version: 3.1.1\n"
7
7
  "Report-Msgid-Bugs-To: fgmacedo@gmail.com\n"
8
8
  "POT-Creation-Date: 2026-05-15 12:08-0300\n"
9
9
  "PO-Revision-Date: 2024-06-07 17:41-0300\n"
@@ -3,7 +3,7 @@
3
3
  #
4
4
  msgid ""
5
5
  msgstr ""
6
- "Project-Id-Version: 3.1.0\n"
6
+ "Project-Id-Version: 3.1.1\n"
7
7
  "Report-Msgid-Bugs-To: fgmacedo@gmail.com\n"
8
8
  "POT-Creation-Date: 2026-05-15 12:08-0300\n"
9
9
  "PO-Revision-Date: 2024-06-07 17:41-0300\n"
@@ -3,7 +3,7 @@
3
3
  #
4
4
  msgid ""
5
5
  msgstr ""
6
- "Project-Id-Version: 3.1.0\n"
6
+ "Project-Id-Version: 3.1.1\n"
7
7
  "Report-Msgid-Bugs-To: fgmacedo@gmail.com\n"
8
8
  "POT-Creation-Date: 2026-05-15 12:08-0300\n"
9
9
  "PO-Revision-Date: 2024-06-07 17:41-0300\n"