migrate to trio so c-lightning sockets stop hanging.

This commit is contained in:
fiatjaf
2020-10-04 12:06:20 -03:00
parent e74cf33f90
commit 9994e61615
15 changed files with 185 additions and 79 deletions
+7 -1
View File
@@ -10,20 +10,26 @@ class Database:
self.connection = sqlite3.connect(db_path)
self.connection.row_factory = sqlite3.Row
self.cursor = self.connection.cursor()
self.closed = False
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
if self.closed:
return
if exc_val:
self.connection.rollback()
self.cursor.close()
self.cursor.close()
self.connection.close()
else:
self.connection.commit()
self.cursor.close()
self.connection.close()
self.closed = True
def commit(self):
self.connection.commit()