~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-25 20:40:48 UTC
  • mto: This revision was merged to the branch mainline in revision 2050.
  • Revision ID: john@arbash-meinel.com-20060825204048-677cae3cf5ff9ead
Report to the user when we are spinning on a lock

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
 
97
97
import os
98
98
import time
99
 
from StringIO import StringIO
 
99
from cStringIO import StringIO
100
100
 
101
101
import bzrlib.config
102
102
from bzrlib.errors import (
111
111
        ResourceBusy,
112
112
        UnlockableTransport,
113
113
        )
114
 
from bzrlib.trace import mutter
 
114
from bzrlib.trace import mutter, note
115
115
from bzrlib.transport import Transport
116
116
from bzrlib.osutils import rand_chars
117
117
from bzrlib.rio import RioWriter, read_stanza, Stanza
160
160
        self._dir_modebits = dir_modebits
161
161
        self.nonce = rand_chars(20)
162
162
 
 
163
        self._report_function = note
 
164
 
163
165
    def __repr__(self):
164
166
        return '%s(%s%s)' % (self.__class__.__name__,
165
167
                             self.transport.base,
355
357
        # XXX: the transport interface doesn't let us guard 
356
358
        # against operations there taking a long time.
357
359
        deadline = time.time() + timeout
 
360
        commented = False
358
361
        while True:
359
362
            try:
360
363
                self.attempt_lock()
361
364
                return
362
365
            except LockContention:
363
366
                pass
 
367
            if not commented:
 
368
                commented = True
 
369
                self._report_function('Unable to obtain lock on %s\n'
 
370
                                      'Will continue to try for %s seconds\n',
 
371
                                      self.transport.abspath(self.path),
 
372
                                      timeout)
 
373
 
364
374
            if time.time() + poll < deadline:
365
375
                time.sleep(poll)
366
376
            else: