~mvo/software-center/lp967036

« back to all changes in this revision

Viewing changes to softwarecenter/utils.py

  • Committer: Michael Vogt
  • Date: 2012-03-27 08:34:36 UTC
  • mto: This revision was merged to the branch mainline in revision 2923.
  • Revision ID: michael.vogt@ubuntu.com-20120327083436-5b42yrasb4gha2im
add locking for expunge-cache.py to ensure that we don't run into races like bug #962580

Show diffs side-by-side

added added

removed removed

Lines of Context:
628
628
    return str(uuid.uuid4())
629
629
 
630
630
 
 
631
def get_lock(path):
 
632
    """ return a lock that can be released with release_lock on success
 
633
        and -1 on failure
 
634
    """
 
635
    try:
 
636
        import apt_pkg
 
637
        return apt_pkg.get_lock(path, False)
 
638
    except ImportError:
 
639
        # implement me on non-apt system, I wish python had this in the stdlib
 
640
        pass
 
641
 
 
642
 
 
643
def release_lock(lock):
 
644
    """ release a lock acquired with get_lock """
 
645
    os.close(lock)
 
646
 
 
647
 
631
648
class SimpleFileDownloader(GObject.GObject):
632
649
 
633
650
    LOG = logging.getLogger("softwarecenter.simplefiledownloader")