Skip to content

Commit 93d8cb4

Browse files
committed
Better handling of already closed sessions.
This patch fixes #416.
1 parent 9fc778d commit 93d8cb4

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

PyFunceble/cli/processes/workers/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
import multiprocessing
5656
from typing import Optional
5757

58+
import sqlalchemy.exc
59+
5860
import PyFunceble.cli.facility
5961
import PyFunceble.cli.factory
6062
import PyFunceble.ext.process_manager
@@ -79,7 +81,10 @@ class WorkerBase(PyFunceble.ext.process_manager.WorkerCore):
7981

8082
def __del__(self) -> None:
8183
if self.db_session is not None:
82-
self.db_session.close()
84+
try:
85+
self.db_session.close()
86+
except sqlalchemy.exc.OperationalError:
87+
pass
8388

8489
def __post_init__(self) -> None:
8590
self.requester = Requester(config=PyFunceble.storage.CONFIGURATION)

PyFunceble/cli/system/launcher.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666

6767
import colorama
6868
import domain2idna
69+
import sqlalchemy.exc
6970
from sqlalchemy.orm import Session
7071

7172
import PyFunceble.checker.utils.whois
@@ -312,7 +313,10 @@ def __init__(self, args: Optional[argparse.Namespace] = None) -> None:
312313

313314
def __del__(self) -> None:
314315
if self.db_session is not None:
315-
self.db_session.close()
316+
try:
317+
self.db_session.close()
318+
except sqlalchemy.exc.OperationalError:
319+
pass
316320

317321
@staticmethod
318322
def print_home_ascii() -> None:

PyFunceble/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
from PyFunceble.storage_facility import get_config_directory
6161

6262
PROJECT_NAME: str = "PyFunceble"
63-
PROJECT_VERSION: str = "4.3.0a18.dev (Blue Duckling: Tulip)"
63+
PROJECT_VERSION: str = "4.3.0a19.dev (Blue Duckling: Tulip)"
6464

6565
DISTRIBUTED_CONFIGURATION_FILENAME: str = ".PyFunceble_production.yaml"
6666

version.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
current_version: '4.3.0a18.dev (Blue Duckling: Tulip)'
1+
current_version: '4.3.0a19.dev (Blue Duckling: Tulip)'
22
deprecated:
33
- 3.0.21
44
- 3.1.20

0 commit comments

Comments
 (0)