~verterok/ubuntuone-client/fix-557160

« back to all changes in this revision

Viewing changes to ubuntuone/syncdaemon/hash_queue.py

  • Committer: Tarmac
  • Author(s): natalia.bidart at canonical
  • Date: 2010-04-21 14:31:47 UTC
  • mfrom: (427.2.2 stop-shadowing-hash)
  • Revision ID: dobey@wayofthemonkey.com-20100421143147-0vx9xjdce79sl7zy
Avoiding shadowing builtin hash.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
from twisted.internet import reactor
29
29
 
30
 
from ubuntuone.storageprotocol.hash import \
 
30
from ubuntuone.storageprotocol.content_hash import \
31
31
    content_hash_factory, crc32
32
32
 
33
33
 
34
34
class StopHashing(Exception):
35
 
    """The current hash was cancelled"""
 
35
    """The current hash was cancelled."""
36
36
 
37
37
 
38
38
class _Hasher(threading.Thread):
88
88
            self.queue.task_done()
89
89
 
90
90
    def stop(self):
91
 
        """Stop the hasher (will be effective in the next loop if a hash
92
 
        is in progress)
 
91
        """Stop the hasher.
 
92
 
 
93
        Will be effective in the next loop if a hash is in progress.
 
94
 
93
95
        """
94
96
        # clear the queue to push a end_mark, just to unblok if we are waiting
95
97
        # for a new item
125
127
        return hasher.content_hash(), crc, size, initial_stat
126
128
 
127
129
    def busy(self):
128
 
        """return whether we are busy"""
 
130
        """Return whether we are busy."""
129
131
        with self.mutex:
130
132
            return self.hashing
131
133
 
132
134
    def cancel_if_running(self, path):
133
 
        """request a cancel/stop of the current hash, if it's == path"""
 
135
        """Request a cancel/stop of the current hash, if it's == path."""
134
136
        with self.mutex:
135
137
            if self.hashing == path:
136
138
                self._should_cancel = path