Skip to content

Commit ad9738c

Browse files
authored
(fix): RuntimeError (#189)
1 parent eecca8a commit ad9738c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pyrogram/storage/sqlite_storage.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,16 @@ class SQLiteStorage(Storage):
119119
def __init__(self, name: str):
120120
super().__init__(name)
121121

122-
self.executor = ThreadPoolExecutor(1)
122+
self._executor = None
123123
self.loop = asyncio.get_event_loop()
124124
self.conn = None # type: sqlite3.Connection | None
125125

126+
@property
127+
def executor(self):
128+
if self._executor is None:
129+
self._executor = ThreadPoolExecutor(1)
130+
return self._executor
131+
126132
def _create_impl(self):
127133
with self.conn:
128134
self.conn.executescript(SCHEMA)
@@ -150,7 +156,8 @@ async def save(self):
150156
async def close(self):
151157
await self.loop.run_in_executor(self.executor, self.conn.close)
152158
self.executor.shutdown()
153-
159+
self._executor = None
160+
154161
async def delete(self):
155162
raise NotImplementedError
156163

0 commit comments

Comments
 (0)