Google Groups

Trac0.11.6 - Cannot operate on a closed cursor

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

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/", line 450, in
File "/home/silk/devel/trac/trac/trac/web/", line 206, in
  resp = chosen_handler.process_request(req)
File "/home/silk/devel/trac/bugtest/bugtest/", line 52, in
  stats = get_ticket_stats(self.stats_provider, tickets)
File "/home/silk/devel/trac/trac/trac/ticket/", line 258, in
  return provider.get_ticket_group_stats([t['id'] for t in tickets])
File "/home/silk/devel/trac/trac/trac/ticket/", line 202, in
File "/home/silk/devel/trac/trac/trac/db/", line 65, in execute
  return self.cursor.execute(sql)
File "/home/silk/devel/trac/trac/trac/db/", line 80, in
  PyFormatCursor.execute(self, *args)
File "/home/silk/devel/trac/trac/trac/db/", line 59, in
  args or [])
File "/home/silk/devel/trac/trac/trac/db/", line 51, in
  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:

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 :)