Remove unnecessary thread safety

This commit is contained in:
Tulir Asokan
2018-02-10 12:13:13 +02:00
parent 55dc1ff3c7
commit a7c81e46e3
4 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -173,7 +173,7 @@ class AppService:
self.log.exception("Exception in Matrix event handler")
for handler in self.event_handlers:
asyncio.ensure_future(try_handle(handler))
asyncio.ensure_future(try_handle(handler), loop=self.loop)
def matrix_event_handler(self, func):
self.event_handlers.append(func)
+2 -2
View File
@@ -87,9 +87,9 @@ with appserv.run(config["appservice.hostname"], config["appservice.port"]) as st
startup_actions += init_user(context)
startup_actions += [start]
try:
loop.run_until_complete(asyncio.gather(*startup_actions))
loop.run_until_complete(asyncio.gather(*startup_actions, loop=loop))
loop.run_forever()
except KeyboardInterrupt:
for user in User.by_tgid.values():
user.client.disconnect()
user.stop()
sys.exit(0)
+1 -1
View File
@@ -844,7 +844,7 @@ class Portal:
def migrate_and_save(self, new_id):
existing = DBPortal.query.get(self.tgid_full)
if existing:
self.db.object_session(existing).delete(existing)
self.db.delete(existing)
try:
del self.by_tgid[self.tgid_full]
except KeyError:
+3 -2
View File
@@ -28,6 +28,7 @@ config = None
class User:
loop = None
log = logging.getLogger("mau.user")
db = None
az = None
@@ -140,7 +141,7 @@ class User:
continue
portal = po.Portal.get_by_entity(entity)
creators.append(portal.create_matrix_room(self, entity, invites=[self.mxid]))
await asyncio.gather(*creators)
await asyncio.gather(*creators, loop=self.loop)
# endregion
# region Telegram update handling
@@ -316,7 +317,7 @@ class User:
def init(context):
global config
User.az, User.db, config, _ = context
User.az, User.db, config, User.loop = context
users = [User.from_db(user) for user in DBUser.query.all()]
return [user.start() for user in users]