Google Groups

Trac0.11.6 - Cannot operate on a closed cursor


Grzegorz Sobanski Nov 23, 2009 5:19 AM
Posted in group: Trac Development
Hi.

I upgraded my installations to latest 0.11 stable (8846).
Unfortunately it killed my custom plugin, tracking lead me to commit
8590 that enabled connetion pooling on linux.

In my plugin I'm reusing generating ticket group stats from roadmap to
display similar progress bars.

Some simplified code is here that triggers the error:
"Cannot operate on a closed cursor"

    def process_request(self, req):
        tickets = get_tickets_for_milestone(self.env, self.env.get_db_cnx(), "milestone2")
        stats = get_ticket_stats(self.stats_provider, tickets)
        [...]

I get a stacktrace:
File "/home/silk/devel/trac/trac/trac/web/main.py", line 450, in
_dispatch_request
  dispatcher.dispatch(req)
File "/home/silk/devel/trac/trac/trac/web/main.py", line 206, in
dispatch
  resp = chosen_handler.process_request(req)
File "/home/silk/devel/trac/bugtest/bugtest/web_ui.py", line 52, in
process_request
  stats = get_ticket_stats(self.stats_provider, tickets)
File "/home/silk/devel/trac/trac/trac/ticket/roadmap.py", line 258, in
get_ticket_stats
  return provider.get_ticket_group_stats([t['id'] for t in tickets])
File "/home/silk/devel/trac/trac/trac/ticket/roadmap.py", line 202, in
get_ticket_group_stats
  ",".join(str_ids))
File "/home/silk/devel/trac/trac/trac/db/util.py", line 65, in execute
  return self.cursor.execute(sql)
File "/home/silk/devel/trac/trac/trac/db/sqlite_backend.py", line 80, in
execute
  PyFormatCursor.execute(self, *args)
File "/home/silk/devel/trac/trac/trac/db/sqlite_backend.py", line 59, in
execute
  args or [])
File "/home/silk/devel/trac/trac/trac/db/sqlite_backend.py", line 51, in
_rollback_on_error
  return function(self, *args, **kwargs)

But the roadmap view is working fine, so it seems I'm doing something
totally wrong.

Simplifing more I came to this code, that gives the same error:

    def process_request(self, req):
        cursor = self.env.get_db_cnx().cursor()
        cursor.execute("SELECT status, count(status) FROM ticket "
                       "WHERE id IN (3) GROUP BY status")

Anoyone has any clue what I'am doing wrong?
It seems to be an error very similar to #8569 (although roadmap and
timeline work fine for me). I have seens similar bugreports on
trac-hacks, but with no resolution.

I put a very simple module reproducing the crash at:
http://boktor.net/pliki/bugs/bugtest.tgz

System info:
debian sid
Trac:   0.11.6stable    [8846]
Python:     2.5.4 (r254:67916, Sep 26 2009, 10:32:22) [GCC 4.3.4]
setuptools:     0.6c9
SQLite:     3.6.20
pysqlite:   2.5.5
Genshi:     0.5.1
Pygments:   1.1.1
Subversion:     1.6.6 (r40053)
jQuery: 1.2.6

hope someone can help me :)

greets
silk