Modify

Opened 5 years ago

Closed 4 years ago

Last modified 10 months ago

#6341 closed defect (fixed)

Cannot operate on a closed cursor error

Reported by: lkraav Owned by: lkraav
Priority: normal Component: TracPastePlugin
Severity: normal Keywords: ProgrammingError, closed, cursor
Cc: otaku42 Trac Release: 0.11

Description (last modified by rjollos)

2009-12-16 14:26:35,474 Trac[chrome] DEBUG: Prepare chrome data for request
2009-12-16 14:26:35,478 Trac[model] DEBUG: get_pastes() SQL: 'SELECT id, title, author, time FROM pastes ORDER BY id DESC LIMIT 10' (None)
2009-12-16 14:26:35,599 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
  File "/secure/trac/virtual-0.11/trac-src/trac/web/main.py", line 450, in _dispatch_request
    dispatcher.dispatch(req)
  File "/secure/trac/virtual-0.11/trac-src/trac/web/main.py", line 206, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/tracpaste/web_ui.py", line 141, in process_request
    'recent':           get_pastes(env=self.env, number=self.max_recent)
  File "build/bdist.linux-i686/egg/tracpaste/model.py", line 53, in get_pastes
    cursor.execute(sql, where_values)
  File "/secure/trac/virtual-0.11/trac-src/trac/db/util.py", line 65, in execute
    return self.cursor.execute(sql)
  File "/secure/trac/virtual-0.11/trac-src/trac/db/sqlite_backend.py", line 80, in execute
    PyFormatCursor.execute(self, *args)
  File "/secure/trac/virtual-0.11/trac-src/trac/db/sqlite_backend.py", line 59, in execute
    args or [])
  File "/secure/trac/virtual-0.11/trac-src/trac/db/sqlite_backend.py", line 51, in _rollback_on_error
    return function(self, *args, **kwargs)
ProgrammingError: Cannot operate on a closed cursor.

Attachments (0)

Change History (9)

comment:1 Changed 5 years ago by lkraav

this could be related to #6302.

comment:2 Changed 4 years ago by rjollos

  • Description modified (diff)
  • Summary changed from TracPastePlugin: 0.11.6 - Cannot operate on a closed cursor error to Cannot operate on a closed cursor error

#7138 was closed as a duplicate.

comment:3 Changed 4 years ago by rjollos

  • Cc otaku42 added; anonymous removed

Isn't this (source:tracpasteplugin/0.11/tracpaste/model.py@4949#L31)

cursor = (db or env.get_db_cnx()).cursor()

just as bad of a practice as?:

cursor = env.get_db_cnx().cursor

Shouldn't we replace that code with?:

db = (db or env.get_db_cnx())
cursor = db.cursor()

Per t:wiki:TracDev/DatabaseApi#APIbeforeTrac0.12

comment:4 Changed 4 years ago by rjollos

Since I have TracPastePlugin setup in a dev environment following #8298, I'd be happy to apply the proposed fix for this as well, given permission of the maintainer.

  • 0.11/tracpaste/model.py

     
    2828
    2929    To get the paste data, use id to instantiate a Paste object."""
    3030
    31     cursor = (db or env.get_db_cnx()).cursor()
     31    db = db or env.get_db_cnx()
     32    cursor = db.cursor()
    3233
    3334    sql = "SELECT id, title, author, time FROM pastes"
    3435    order_clause = " ORDER BY id DESC"

comment:5 Changed 4 years ago by rjollos

#6361 closed as a duplicate.

comment:6 Changed 4 years ago by osimons

Patch looks good to me.

comment:7 Changed 4 years ago by otaku42

No objections from me. Feel free to commit.

comment:8 Changed 4 years ago by rjollos

  • Resolution set to fixed
  • Status changed from new to closed

(In [9678]) Attempt to resolve reported closed cursor error by making sure db object does not get removed up by Python. Version bumped to 0.2.2. Fixes #6341.

comment:9 Changed 10 months ago by rjollos

  • Keywords ProgrammingError closed cursor added

Add Comment

Modify Ticket

Action
as closed The owner will remain lkraav.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.