Merge pull request #10 from andreped:shared-memory
Browse filesImplement singleton for shared memory between sessions
- app.py +3 -6
- postly/clients/singleton_client.py +11 -0
app.py
CHANGED
@@ -1,12 +1,9 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
from postly.clients.
|
4 |
|
5 |
-
# Initialize the PostlyClient
|
6 |
-
|
7 |
-
st.session_state.client = PostlyClient()
|
8 |
-
|
9 |
-
client = st.session_state.client
|
10 |
|
11 |
# Initialize user session state
|
12 |
if "logged_in" not in st.session_state:
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
from postly.clients.singleton_client import SingletonPostlyClient
|
4 |
|
5 |
+
# Initialize the PostlyClient singleton
|
6 |
+
client = SingletonPostlyClient.get_instance()
|
|
|
|
|
|
|
7 |
|
8 |
# Initialize user session state
|
9 |
if "logged_in" not in st.session_state:
|
postly/clients/singleton_client.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from .postly_client import PostlyClient
|
2 |
+
|
3 |
+
|
4 |
+
class SingletonPostlyClient:
|
5 |
+
_instance = None
|
6 |
+
|
7 |
+
@staticmethod
|
8 |
+
def get_instance():
|
9 |
+
if SingletonPostlyClient._instance is None:
|
10 |
+
SingletonPostlyClient._instance = PostlyClient()
|
11 |
+
return SingletonPostlyClient._instance
|