Skip to content

Commit

Permalink
Fix serialization problem in the atomic decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
epandurski committed Mar 22, 2022
1 parent e495ab5 commit ebf8975
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

Version 0.5.7
-------------

- Fixed bug in the `atomic` decorator. Before this fix, not all
database serialization errors resulted in a retry.


Version 0.5.6
-------------

Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
# built documents.
#
# The short X.Y version.
version = '0.5.6'
version = '0.5.7'
# The full version, including alpha/beta/rc tags.
release = '0.5.6'
release = '0.5.7'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -138,7 +138,7 @@
# The name for this set of Sphinx documents.
# "<project> v<release> documentation" by default.
#
# html_title = 'Flask-SignalBus v0.5.6'
# html_title = 'Flask-SignalBus v0.5.7'

# A shorter title for the navigation bar. Default is the same as html_title.
#
Expand Down
9 changes: 7 additions & 2 deletions flask_signalbus/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,16 @@ def wrapper(*args, **kwargs):
session_info = session.info
if session_info.get(_ATOMIC_FLAG_SESSION_INFO_KEY):
return func(*args, **kwargs)
f = retry_on_deadlock(session)(func)

@retry_on_deadlock(session)
def f(*args, **kwargs):
r = func(*args, **kwargs)
session.flush()
return r

session_info[_ATOMIC_FLAG_SESSION_INFO_KEY] = True
try:
result = f(*args, **kwargs)
session.flush()
session.expunge_all()
session.commit()
return result
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

setup(
name='Flask-SignalBus',
version='0.5.6',
version='0.5.7',
url='https://github.com/epandurski/flask_signalbus',
license='MIT',
author='Evgeni Pandurski',
Expand Down

0 comments on commit ebf8975

Please sign in to comment.