Modify

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11000 closed defect (fixed)

Leaking resources by incorrect use of `open_environment`

Reported by: Jun Omae Owned by: Jeff Hammel
Priority: normal Component: TicketMoverPlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

Original issue at trac:#11139.

The following error is caused by incorrect use of open_environment.

OSError: [Errno 24] Too many open files: '/opt/trac'

open_environment without use_cache creates every time a new instance of Environment. However, TicketMoverPlugin doesn't release nor cache. Therefore, some resources leak.

  • ticketmoverplugin/ticketmover.py

     
    155155        for project in _projects:
    156156            path = os.path.join(base_path, project)
    157157            try:
    158                 env = open_environment(path)
     158                env = open_environment(path, use_cache=True)
    159159            except:
    160160                continue
    161161            perm = PermissionSystem(env)
     
    176176        # open the environment if it is a string
    177177        if isinstance(env, basestring):
    178178            base_path, _project = os.path.split(self.env.path)
    179             env = open_environment(os.path.join(base_path, env))
     179            env = open_environment(os.path.join(base_path, env), use_cache=True)
    180180
    181181        # get the old ticket
    182182        old_ticket = Ticket(self.env, ticket_id)

Attachments (0)

Change History (4)

comment:1 Changed 11 years ago by Ryan J Ollos

jun66j5: k0s is no longer active in the Trac community and has given permission for his plugins to be adopted, so feel free to push the patch directly to the repository.

comment:2 Changed 11 years ago by Jun Omae

Resolution: fixed
Status: newclosed

(In [12863]) TicketMoverPlugin: fix #11000: leaking resources caused by open_environment

comment:3 Changed 11 years ago by Ryan J Ollos

jun66j5: #11091 reports a significant slowdown when using this plugin. We aren't sure yet which version is being used, but do you think the issue you fixed here could be the cause?

comment:4 Changed 11 years ago by Jun Omae

Yes. I think that the slowdown in #11091 has been fixed by [12863].

Before the changes, Trac constructs all tracenvs using open_environment on every request while viewing ticket page. After the changes, Trac uses Environment instances in the cache.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jeff Hammel.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.