INNER CODE UNIT · Python
register
ok-oldking/ok-script · ok/ui/web/app.py:90
def register(self, session_key, wake):
token = object()
with self._lock:
previous = self._active.get(session_key)
self._active[session_key] = (token, wake)
if previous is not None:
previous[1]()
return token
def is_active(self, session_key, token):
with self._lock:
current = self._active.get(session_key)
return current is not None and current[0] is token
def unregister(self, session_key, token):
with self._lock:
current = self._active.get(session_key)
if current is not None and current[0] is token: