Spaces:
Build error
Build error
| # Hacky way to provide global session. | |
| import sys | |
| GLOBAL_CONTAINER = sys | |
| class GlobalState(object): | |
| def __new__(cls, key="default"): | |
| if not hasattr(GLOBAL_CONTAINER, '_global_states'): | |
| GLOBAL_CONTAINER._global_states = {} | |
| print("Global state container created") | |
| if not GLOBAL_CONTAINER._global_states.get(key): | |
| GLOBAL_CONTAINER._global_states[key] = super(GlobalState, cls).__new__(cls) | |
| return GLOBAL_CONTAINER._global_states[key] | |