~fginther/jenkins-launchpad-plugin/dev-disable-gensymbols

« back to all changes in this revision

Viewing changes to voteOnMergeProposal.py

launchpadlib is not threadsafe -- lock all usage. Fixes: https://bugs.launchpad.net/bugs/1025153. Approved by Sergio Schvezov, jenkins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import sys
4
4
from argparse import ArgumentParser
5
5
from launchpad import LaunchpadTrigger
6
 
 
 
6
from settings import LOCK_FILE, logger
 
7
from lockfile import FileLock
7
8
 
8
9
def main():
9
10
    parser = ArgumentParser(description="Vote on a Launchpad merge proposal.")
35
36
 
36
37
 
37
38
if __name__ == "__main__":
38
 
    sys.exit(main())
 
39
    # this is here because launchpadlib is not thread safe (yet)
 
40
    # see also lp:459418 and lp:1025153
 
41
    logger.debug('Going to acquire launchpad lock for voteOnMergeProposal')
 
42
    with FileLock(LOCK_FILE):
 
43
        logger.debug('Lock acquired for voteOnMergeProposal')
 
44
        sys.exit(main())