@web.background gotcha
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
web.py |
Fix Released
|
High
|
Anand Chitipothu |
Bug Description
Here is the problem.
http://
And here is the fix.
def background(func):
"""A function decorator to run a long-running function as a
background thread.
+ GOTCHA: Until the foreground task ends, any db access by
background task
+ will necessarily get old data from before the foreground task
started
+ because psycopg2 begins a transaction in the foreground task
until it quits """
def internal(*a, **kw):
web.data() # cache it
tmpctx = web._context[
utils.storage(
def newfunc():
+ # Create new db cursor if there is one else background thread
+ # overwrites foreground cursor causing rubbish data into dbase
+ if web.config.
+ webdb.connect(
Related branches
Changed in webpy: | |
assignee: | nobody → anandology |
importance: | Undecided → High |
status: | New → In Progress |
Changed in webpy: | |
milestone: | 0.22 → 0.23 |
Changed in webpy: | |
status: | In Progress → Fix Committed |
Changed in webpy: | |
status: | Fix Committed → Fix Released |