[tor-commits] [sbws/master] settings: add class to store end event singleton

juga at torproject.org juga at torproject.org
Mon Feb 4 14:57:14 UTC 2019


commit ea50a75040cbed3db363147788d6088347e8969e
Author: juga0 <juga at riseup.net>
Date:   Tue Jan 8 14:46:52 2019 +0000

    settings: add class to store end event singleton
---
 sbws/__init__.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/sbws/__init__.py b/sbws/__init__.py
index 4256404..3871edb 100644
--- a/sbws/__init__.py
+++ b/sbws/__init__.py
@@ -1 +1,25 @@
 __version__ = '1.0.3-dev0'
+
+
+import threading  # noqa
+
+
+class Settings:
+    """Singleton settings for all the packages.
+    This way change settings can be seen by all the packages that import it.
+
+    It lives in ``__init__.py`` to leave open the possibility of having a
+    ``settings.py`` module for user settings.
+
+    .. note:: After refactoring, globals should only have constants.
+      Any other variable that needs to be modified when initializing
+      should be initialized here.
+
+    """
+    def __init__(self):
+        self.end_event = threading.Event()
+
+    def set_end_event(self):
+        self.end_event.set()
+
+settings = Settings()  # noqa





More information about the tor-commits mailing list