Modify

Opened 4 years ago

Closed 16 months ago

Last modified 16 months ago

#9984 closed defect (fixed)

trac-admin script hangs when TracDeveloperPlugin is enabled

Reported by: anonymous Owned by: jun66j5
Priority: normal Component: TracDeveloperPlugin
Severity: normal Keywords:
Cc: rjollos Trac Release: 0.12

Description

Then the TracDeveloperPlugin is enabled, the trac-admin script does not exit after it is done. This only happens for trac-admin subcommands that load the plugin, like e.g. trac-admin deploy.

I guess this is because of the thread started by the plugin.

Attachments (0)

Change History (13)

comment:1 Changed 4 years ago by rjollos

  • Cc rjollos added; anonymous removed

comment:2 Changed 4 years ago by rjollos

  • Owner changed from athomas to olemis

comment:3 follow-up: Changed 3 years ago by olemis

  • Owner changed from olemis to anonymous
  • Status changed from new to assigned

comment:4 in reply to: ↑ 3 Changed 3 years ago by rjollos

Replying to olemis:

  • Owner changed from olemis to anonymous

I've noticed this a few times when you've accepted tickets - if you accept a ticket without logging in, it will be assigned to anonymous. Just fyi. See also #7397 and #11455.

I'll see if we can modify the workflow to avoid this scenario.

comment:5 follow-up: Changed 3 years ago by olemis

I can't reproduce this issue running Trac=1.0 . May I close this ticket with resolution=worksforme ?

@rjollos : I typed my user name in author box . So ... maybe this is an issue ?

I'm honestly not keen to login to web sites unless they offer open auth mechanisms e.g. OpenId

comment:6 Changed 3 years ago by rjollos

I replied to your comment in comment:2:ticket:11457.

comment:7 Changed 2 years ago by jun66j5

  • Owner changed from anonymous to olemis

comment:8 in reply to: ↑ 5 Changed 16 months ago by rjollos

Replying to olemis:

I can't reproduce this issue running Trac=1.0.

Reproduced with Trac trunk (trac:r14100) and TracDeveloperPlugin r14629 using trac-admin deploy. Here is the DEBUG level console output before the hang:

Copying resources from:
  trac.web.chrome.Chrome
    /Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/htdocs
    /Users/rjollos/Documents/Workspace/trac-dev/proj-1.1/htdocs
  tracdeveloper.main.DeveloperPlugin
    /Users/rjollos/Documents/Workspace/trac-dev/tracdeveloperplugin/trunk/tracdeveloper/htdocs
  tracdeveloper.dozer.Dozer
    /Users/rjollos/Documents/Workspace/trac-dev/tracdeveloperplugin/trunk/tracdeveloper/dozer/htdocs
Creating scripts.
14:36:15 Trac[__init__] DEBUG: templates=/Users/rjollos/Documents/Workspace/trac-dev/tracdeveloperplugin/trunk/tracdeveloper/dozer/templates

comment:9 Changed 16 months ago by jun66j5

Reproduced with Trac 1.0.6. I consider that issue must be reproduced with all versions of Trac.

When constructing Dozer component in tracdeveloper/dozer/__init__.py, the component creates a non-daemon thread. As the result, the python interpreter waits termination of the thread.

  • tracdeveloperplugin/trunk/tracdeveloper/dozer/__init__.py

    diff --git a/tracdeveloperplugin/trunk/tracdeveloper/dozer/__init__.py b/tracdeveloperplugin/trunk/tracdeveloper/dozer/__init__.py
    index aa1f247..0d9249c 100644
    a b class Dozer(Component): 
    7171        self.history = {}
    7272        self.samples = 0
    7373        self.runthread = threading.Thread(target=self.start)
     74        self.runthread.setDaemon(True)
    7475        self.runthread.start()
    7576
    7677    # IRequestHandler methods

Another suggestion is removing ITemplateProvider implementation from the Dozer component (or moving it to another component).

Last edited 16 months ago by rjollos (previous) (diff)

comment:10 Changed 16 months ago by rjollos

Thank you for the suggestion and patch. How does the following look?

  • tracdeveloper/dozer/__init__.py

     
    77from StringIO import StringIO
    88from types import FrameType, ModuleType
    99
    10 from pkg_resources import resource_filename
    1110#
    1211# import Image
    1312# import ImageDraw
     
    1413
    1514from trac.core import *
    1615from trac.web.api import IRequestHandler, HTTPNotFound, HTTPForbidden
    17 from trac.web.chrome import ITemplateProvider, add_stylesheet, add_script
     16from trac.web.chrome import add_stylesheet, add_script
    1817
    1918from genshi.core import Markup
    2019from genshi.builder import tag
     
    2120
    2221# from paste import fileapp
    2322# from paste import urlparser
    24 # from pkg_resources import resource_filename
    2523# from webob import Request, Response
    2624# from webob import exc
    2725
     
    6563    period = 5
    6664    maxhistory = 300
    6765   
    68     implements(IRequestHandler, ITemplateProvider)
     66    implements(IRequestHandler)
    6967   
    7068    def __init__(self):
    7169        self.history = {}
    7270        self.samples = 0
    7371        self.runthread = threading.Thread(target=self.start)
     72        self.runthread.setDaemon(True)
    7473        self.runthread.start()
    7574   
    7675    # IRequestHandler methods
     
    9392        add_stylesheet(req, 'dozer/main.css')
    9493        return method(req)
    9594   
    96     # ITemplateProvider methods
    97     def get_htdocs_dirs(self):
    98         yield 'dozer', resource_filename(__name__, 'htdocs')
    99            
    100     def get_templates_dirs(self):
    101         self.log.debug('templates=%s', resource_filename(__name__, 'templates'))
    102         yield resource_filename(__name__, 'templates')
    103    
    10495    # Internal methods
    10596    def start(self):
    10697        self.running = True
  • tracdeveloper/main.py

     
    4343
    4444    def get_templates_dirs(self):
    4545        from pkg_resources import resource_filename
    46         return [resource_filename(__name__, 'templates')]
     46        return [resource_filename('tracdeveloper', 'templates'),
     47                resource_filename('tracdeveloper.dozer', 'templates')]
    4748
    4849    def get_htdocs_dirs(self):
    4950        from pkg_resources import resource_filename
    50         return [('developer', resource_filename(__name__, 'htdocs'))]
     51        return [('developer', resource_filename('tracdeveloper', 'htdocs')),
     52                ('dozer', resource_filename('tracdeveloper.dozer', 'htdocs'))]
    5153
    5254    # IPreferencePanelProvider methods
    5355    def get_preference_panels(self, req):

comment:11 Changed 16 months ago by jun66j5

Looks good to me!

comment:12 Changed 16 months ago by rjollos

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

In 14644:

0.3.0dev: Fix trac-admin script hanging. Fixes #9984.

  • Dozer thread runs in daemon mode.
  • ITemplateProvider moved from dozer to main.

Thanks to Jun Omae for the patch.

comment:13 Changed 16 months ago by rjollos

  • Owner changed from olemis to jun66j5

Add Comment

Modify Ticket

Action
as closed The owner will remain jun66j5.
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.