~nataliabidart/magicicada-client/snapping

« back to all changes in this revision

Viewing changes to ubuntuone/syncdaemon/offload_queue.py

  • Committer: Magicicada Bot
  • Author(s): Natalia
  • Date: 2015-09-19 23:23:53 UTC
  • mfrom: (1408.1.1 fix-lint-tests)
  • Revision ID: magicicada_bot-20150919232353-cadtca1w1sh5mu7c
[r=nataliabidart] - Fixed lint issues on ubuntuone/ folder.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
    # limits for file rotation...
46
46
    # after the soft limit, we'll rotate if queue is short enough
47
 
    _rotation_soft_limit =  2 * 1024 ** 3
 
47
    _rotation_soft_limit = 2 * 1024 ** 3
48
48
    # if the queue is shorter than this, we'll rotate after the soft limit
49
49
    _rotation_too_big_size = 50 * 1024 ** 2
50
50
    # rotate if file gets larger than this, no matter the queue size
69
69
        # fallback to memory if something goes wrong when using disk
70
70
        self._in_memory = False
71
71
 
72
 
    def  __len__(self):
 
72
    def __len__(self):
73
73
        return self._len
74
74
 
75
75
    def push(self, item):
91
91
        self._tempfile_size += len(data) + STRUCT_SIZE
92
92
        self._rotate()
93
93
 
94
 
    def  _handle_bad_write(self, data):
 
94
    def _handle_bad_write(self, data):
95
95
        """Support a bad write, go to memory and continue."""
96
96
        self.log.exception("Crashed while writing")
97
97
 
135
135
        # the file is big, let's check if we would need to copy too much data
136
136
        if queuesize > self._rotation_too_big_size:
137
137
            # avoid rotation only if file size is still below the hard limit
138
 
             if filesize < self._rotation_hard_limit:
 
138
            if filesize < self._rotation_hard_limit:
139
139
                return
140
140
 
141
141
        # rotate to a new file