Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix v4.1.1: Add rollback transaction action in the Storage class exception handling #55

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).


## v4.1.1 - 2025-03-17
### What's Changed
**Full Changelog**: https://github.com/obervinov/users-package/compare/v4.1.0...v4.1.1 by @obervinov in https://github.com/obervinov/users-package/pull/55
#### 🐛 Bug Fixes
* add `rollback transaction` action in the `Storage` class exception handling block to prevent critical exceptions from breaking the database connection


## v4.1.0 - 2025-02-21
### What's Changed
**Full Changelog**: https://github.com/obervinov/users-package/compare/v4.0.2...v4.1.0 by @obervinov in https://github.com/obervinov/users-package/pull/54
Expand Down
13 changes: 7 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "users"
version = "4.1.0"
version = "4.1.1"
description = "This python module is a simple implementation of user management functionality for telegram bots, such as: authentication, authorization and requests limiting."
authors = ["Bervinov Oleg <[email protected]>"]
maintainers = ["Bervinov Oleg <[email protected]>"]
Expand Down
8 changes: 4 additions & 4 deletions users/storage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This module contains the storage class for the storage of user data: requests, access logs, etc."""
import json
import time
import psycopg2
from logger import log
from .exceptions import FailedStorageConnection
Expand All @@ -15,10 +14,11 @@ def wrapper(self, *args, **kwargs):
return method(self, *args, **kwargs)
except psycopg2.Error as exception:
log.warning('[Users]: Connection to the database was lost: %s. Attempting to reconnect...', str(exception))
time.sleep(5)
try:
self.database_connection = self.create_connection()
log.info('[Users]: Reconnection successful.')
self.connection.close()
self.connection = self.create_connection()
self.cursor = self.connection.cursor()
log.info('[Users]: Reconnection successful. Retrying the method...')
return method(self, *args, **kwargs)
except psycopg2.Error as inner_exception:
log.error('[Users]: Failed to reconnect to the database: %s', str(inner_exception))
Expand Down
Loading