~powersj/jenkins-launchpad-plugin/autoland-git

« back to all changes in this revision

Viewing changes to jlp/commands/autoland.py

  • Committer: Tarmac
  • Author(s): Parameswaran Sivatharman
  • Date: 2015-09-25 08:31:14 UTC
  • mfrom: (124.2.6 stop-tmp-leak)
  • Revision ID: tarmac-20150925083114-h9cp5dgwmljheuft
Fix to wrap the launchpadlib leaking launchpadlib_cache directory.

Approved by Francis Ginther, PS Jenkins bot, Joe Talbott.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import re
2
2
from argparse import ArgumentParser
3
3
import argparse
 
4
import atexit
4
5
from jlp.launchpadutils import build_state, LaunchpadVote, get_vote_subject
5
6
from jlp import (launchpadutils, Branch,
6
7
                 DputRunner, jenkinsutils, get_launchpad,
222
223
    launchpad_cachedir = os.path.join('/tmp',
223
224
                                      str(os.getpid()),
224
225
                                      '.launchpadlib')
 
226
 
 
227
    # `launchpad_cachedir` is leaked upon unexpected exits
 
228
    # adding this cleanup to stop directories filling up `/tmp/`
 
229
    atexit.register(rmtree, os.path.join('/tmp',
 
230
                                         str(os.getpid())),
 
231
                    ignore_errors=True)
225
232
    lp_handle = get_launchpad(launchpadlib_dir=launchpad_cachedir)
226
233
    mp = launchpadutils.get_mp_handle_from_url(lp_handle,
227
234
                                               args['merge_proposal'])
253
260
 
254
261
    # merging starts here
255
262
    ret = merge_and_commit(mp, args)
256
 
    rmtree(launchpad_cachedir, ignore_errors=True)
257
263
    return ret