python-statemachine 2.3.0__tar.gz → 2.3.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.
Files changed (28) hide show
  1. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/PKG-INFO +2 -2
  2. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/README.md +1 -1
  3. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/pyproject.toml +1 -1
  4. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/__init__.py +1 -1
  5. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/utils.py +10 -4
  6. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/LICENSE +0 -0
  7. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/callbacks.py +0 -0
  8. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/contrib/__init__.py +0 -0
  9. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/contrib/diagram.py +0 -0
  10. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/dispatcher.py +0 -0
  11. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/event.py +0 -0
  12. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/event_data.py +0 -0
  13. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/events.py +0 -0
  14. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/exceptions.py +0 -0
  15. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/factory.py +0 -0
  16. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/graph.py +0 -0
  17. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/i18n.py +0 -0
  18. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/locale/en/LC_MESSAGES/statemachine.po +0 -0
  19. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/locale/pt_BR/LC_MESSAGES/statemachine.po +0 -0
  20. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/mixins.py +0 -0
  21. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/model.py +0 -0
  22. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/registry.py +0 -0
  23. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/signature.py +0 -0
  24. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/state.py +0 -0
  25. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/statemachine.py +0 -0
  26. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/states.py +0 -0
  27. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/transition.py +0 -0
  28. {python_statemachine-2.3.0 → python_statemachine-2.3.1}/statemachine/transition_list.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-statemachine
3
- Version: 2.3.0
3
+ Version: 2.3.1
4
4
  Summary: Python Finite State Machines made easy.
5
5
  Home-page: https://github.com/fgmacedo/python-statemachine
6
6
  License: MIT
@@ -43,7 +43,7 @@ Python [finite-state machines](https://en.wikipedia.org/wiki/Finite-state_machin
43
43
  </div>
44
44
 
45
45
  Welcome to python-statemachine, an intuitive and powerful state machine library designed for a
46
- great developer experience. We provide an _pythonic_ and expressive API for implementing state
46
+ great developer experience. We provide a _pythonic_ and expressive API for implementing state
47
47
  machines in sync or asynchonous Python codebases.
48
48
 
49
49
  ## Features
@@ -17,7 +17,7 @@ Python [finite-state machines](https://en.wikipedia.org/wiki/Finite-state_machin
17
17
  </div>
18
18
 
19
19
  Welcome to python-statemachine, an intuitive and powerful state machine library designed for a
20
- great developer experience. We provide an _pythonic_ and expressive API for implementing state
20
+ great developer experience. We provide a _pythonic_ and expressive API for implementing state
21
21
  machines in sync or asynchonous Python codebases.
22
22
 
23
23
  ## Features
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-statemachine"
3
- version = "2.3.0"
3
+ version = "2.3.1"
4
4
  description = "Python Finite State Machines made easy."
5
5
  authors = ["Fernando Macedo <fgmacedo@gmail.com>"]
6
6
  maintainers = [
@@ -3,6 +3,6 @@ from .statemachine import StateMachine
3
3
 
4
4
  __author__ = """Fernando Macedo"""
5
5
  __email__ = "fgmacedo@gmail.com"
6
- __version__ = "2.3.0"
6
+ __version__ = "2.3.1"
7
7
 
8
8
  __all__ = ["StateMachine", "State"]
@@ -1,4 +1,8 @@
1
1
  import asyncio
2
+ import threading
3
+
4
+ _cached_loop = threading.local()
5
+ """Loop that will be used when the SM is running in a synchronous context. One loop per thread."""
2
6
 
3
7
 
4
8
  def qualname(cls):
@@ -23,11 +27,13 @@ def ensure_iterable(obj):
23
27
 
24
28
  def run_async_from_sync(coroutine):
25
29
  """
26
- Run an async coroutine from a synchronous context.
30
+ Compatibility layer to run an async coroutine from a synchronous context.
27
31
  """
32
+ global _cached_loop
28
33
  try:
29
- loop = asyncio.get_running_loop()
34
+ asyncio.get_running_loop()
30
35
  return asyncio.ensure_future(coroutine)
31
36
  except RuntimeError:
32
- loop = asyncio.get_event_loop()
33
- return loop.run_until_complete(coroutine)
37
+ if not hasattr(_cached_loop, "loop"):
38
+ _cached_loop.loop = asyncio.new_event_loop()
39
+ return _cached_loop.loop.run_until_complete(coroutine)