Fixed ServerCallThread callbacks

This commit is contained in:
Eric Froemling 2020-04-09 22:22:41 -07:00
parent fa17c88642
commit 64aff1306f
2 changed files with 9 additions and 7 deletions

View File

@ -87,16 +87,18 @@ class ServerCallThread(threading.Thread):
activity) if activity is not None else None
def _run_callback(self, arg: Union[None, Dict[str, Any]]) -> None:
# If we were created in an activity context and that activity has
# since died, do nothing (hmm should we be using a context-call
# instead of doing this manually?).
activity = None if self._activity is None else self._activity()
if activity is None or activity.is_expired():
return
# since died, do nothing.
# FIXME: Should we just be using a ContextCall instead of doing
# this check manually?
if self._activity is not None:
activity = self._activity()
if activity is None or activity.is_expired():
return
# Technically we could do the same check for session contexts,
# but not gonna worry about it for now.
assert self._context is not None
assert self._callback is not None
with self._context:
self._callback(arg)

View File

@ -88,7 +88,7 @@ class StoreBrowserWindow(ba.Window):
self._request: Any = None
self._r = 'store'
self._last_buy_time: Optional[Union[float, int]] = None
self._last_buy_time: Optional[float] = None
super().__init__(root_widget=ba.containerwidget(
size=(self._width, self._height + extra_top),