diff options
| author | 2018-07-02 12:13:54 +0100 | |
|---|---|---|
| committer | 2018-07-02 12:13:54 +0100 | |
| commit | f6a5d97842715f9702c8e4b76dacc21054fd22d2 (patch) | |
| tree | f95f54a1772e834bd3a023d3628b4fed0d3bb02c | |
| parent | Don't add a server to bot.servers until it's connected (diff) | |
| signature | ||
Don't make a database cursor per thread as there should only be 1 thread
| -rw-r--r-- | Database.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Database.py b/Database.py index d1cc66ce..a7a0b285 100644 --- a/Database.py +++ b/Database.py @@ -8,7 +8,7 @@ class Database(object): self.database = sqlite3.connect(self.full_location, check_same_thread=False, isolation_level=None) self.database.execute("PRAGMA foreign_keys = ON") - self.cursors = {} + self._cursor = None self.make_servers_table() self.make_bot_settings_table() @@ -17,10 +17,9 @@ class Database(object): self.make_user_settings_table() def cursor(self): - id = threading.current_thread().ident - if not id in self.cursors: - self.cursors[id] = self.database.cursor() - return self.cursors[id] + if self._cursor == None: + self._cursor = self.database.cursor() + return self._cursor def make_servers_table(self): try: |
