Fix some errors

This commit is contained in:
Tulir Asokan
2019-09-03 00:17:52 +03:00
parent 87aa0b6659
commit d6294ebb45
2 changed files with 12 additions and 3 deletions
+4 -1
View File
@@ -346,7 +346,10 @@ class Portal:
await self.invite_to_matrix(invites or [])
return self.mxid
async with self._room_create_lock:
return await self._create_matrix_room(user, entity, invites)
try:
return await self._create_matrix_room(user, entity, invites)
except Exception:
self.log.exception("Fatal error creating Matrix room")
async def _create_matrix_room(self, user: 'AbstractUser', entity: TypeChat, invites: InviteList
) -> Optional[MatrixRoomID]:
+8 -2
View File
@@ -161,6 +161,12 @@ class User(AbstractUser):
# endregion
# region Telegram connection management
async def try_ensure_started(self) -> None:
try:
await self.ensure_started()
except Exception:
self.log.exception("Exception in ensure_started")
def ensure_started(self, even_if_no_session=False) -> Awaitable['User']:
return super().ensure_started(even_if_no_session)
@@ -400,9 +406,9 @@ class User(AbstractUser):
# endregion
def init(context: 'Context') -> List[Awaitable['User']]:
def init(context: 'Context') -> List[Awaitable[None]]:
global config
config = context.config
users = [User.from_db(user) for user in DBUser.all()]
return [user.ensure_started() for user in users if user.tgid]
return [user.try_ensure_started() for user in users if user.tgid]