Grzegorz Sobanski wrote:
> ...
>
> 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
>   

This should work... it worked for me on Windows (older SQLite and 
Pysqlite versions, then same versions) and Linux (same SQLite and 
Pysqlite versions as you), using Trac 0.11.6rc1.

Even with no poolable connections, that connection should normally end 
up in the _active map, and stay there until the shutdown of the request. 
Only with very intensive concurrent db usage will the connection be 
kicked out of _active ... but then, the odds that this happens before 
you use the cursor are quite low. If you see the error systematically, 
it must be something else... which I don't see right now. Please 
continue to debug this issue, I'm very interested in seeing the 
explanation for this.

-- Christian

PS: I had to add the following lines to the process_request, in order to 
get something in the browser, see slightly modified bugtest/web_ui.py 
attached.

--

You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=.


# -*- coding: utf-8 -*-

import inspect
import pkg_resources
import re
from datetime import datetime

from genshi.builder import tag

from trac.core import *
from trac.config import ExtensionOption
from trac.mimeview import Context
from trac.util import escape
from trac.util.html import html
from trac.web.chrome import INavigationContributor
from trac.web.api import IRequestHandler, RequestDone
from trac.util.translation import _

from trac.ticket.model import Milestone
from trac.ticket.roadmap import milestone_stats_data, \
                                get_tickets_for_milestone, get_ticket_stats, \
                                ITicketGroupStatsProvider


class BugtestManagement(Component):
    implements(INavigationContributor, IRequestHandler)

    stats_provider = ExtensionOption('roadmap', 'stats_provider',
                                     ITicketGroupStatsProvider,
                                      'DefaultTicketGroupStatsProvider',
        """Name of the component implementing `ITicketGroupStatsProvider`,
        which is used to collect statistics on groups of tickets for display
        in the roadmap views.""")

    # INavigationContributor methods
    def get_active_navigation_item(self, req):
        return 'bugtest'

    def get_navigation_items(self, req):
        yield ('mainnav', 'bugtest',
           html.A('bugtest', href=req.href.bugtest()))

    # IRequestHandler methods
    def match_request(self, req):
        match = re.match(r'/bugtest/?$', req.path_info)
        if match:
            return True

    
    def process_request(self, req):
        # variant 1
        #tickets = get_tickets_for_milestone(self.env, self.env.get_db_cnx(), 
"milestone2")
        #stats = get_ticket_stats(self.stats_provider, tickets)

        # variant 2
        #stats = self.stats_provider.get_ticket_group_stats(ticket_ids)
        cursor = self.env.get_db_cnx().cursor()
        cursor.execute("SELECT status, count(status) FROM ticket "
                       "WHERE id IN (3) GROUP BY status") 
        c = "Hello World, "
        c += '\n'.join(repr(s) for s in cursor.fetchall())
        c = str(c)
        req.send_header('Content-Length', len(c))
        req.end_headers()
        req.write(c)
        raise RequestDone


Reply via email to