Restrict EventManager calls to the main thread

This commit is contained in:
jesopo 2019-06-22 12:21:44 +01:00
parent 7174e83f14
commit 3eac36d0f5

View file

@ -192,6 +192,9 @@ class EventHook(object):
def _call(self, kwargs: dict, safe: bool, maximum: typing.Optional[int] def _call(self, kwargs: dict, safe: bool, maximum: typing.Optional[int]
) -> typing.List[typing.Any]: ) -> typing.List[typing.Any]:
if not utils.is_main_thread():
raise RuntimeError("Can't call events outside of main thread")
event_path = self._get_path() event_path = self._get_path()
hooks = self.get_hooks() hooks = self.get_hooks()
returns = [] # type: typing.List[typing.Any] returns = [] # type: typing.List[typing.Any]