1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-30 19:46:25 +00:00
bazarr/libs/plex/core/context.py
2018-10-31 17:08:29 +01:00

26 lines
511 B
Python

from threading import Lock
class Context(object):
def __init__(self, **kwargs):
self.kwargs = kwargs
def __getattr__(self, key):
return self.kwargs.get(key)
class ContextStack(object):
def __init__(self):
self._list = []
self._lock = Lock()
def pop(self):
context = self._list.pop()
self._lock.release()
return context
def push(self, **kwargs):
self._lock.acquire()
return self._list.append(Context(**kwargs))