/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/smart/request.py

  • Committer: John Arbash Meinel
  • Date: 2011-04-20 14:27:19 UTC
  • mto: This revision was merged to the branch mainline in revision 5837.
  • Revision ID: john@arbash-meinel.com-20110420142719-advs1k5vztqzbrgv
Fix bug #767177. Be more agressive with file.close() calls.

Our test suite gets a number of thread leaks and failures because it happens to get async
SFTPFile.close() calls. (if an SFTPFile closes due to __del__ it is done as an async request,
while if you call SFTPFile.close() it is done as a synchronous request.)
We have a couple other cases, probably. Namely SFTPTransport.get() also does an async
prefetch of the content, so if you don't .read() you'll also leak threads that think they
are doing work that you want.

The biggest change here, though, is using a try/finally in a generator, which is not 
python2.4 compatible.

Show diffs side-by-side

added added

removed removed

Lines of Context:
446
446
        return ('TokenMismatch', err.given_token, err.lock_token)
447
447
    elif isinstance(err, errors.LockContention):
448
448
        return ('LockContention',)
 
449
    elif isinstance(err, MemoryError):
 
450
        # GZ 2011-02-24: Copy bzrlib.trace -Dmem_dump functionality here?
 
451
        return ('MemoryError',)
449
452
    # Unserialisable error.  Log it, and return a generic error
450
453
    trace.log_exception_quietly()
451
 
    return ('error', str(err))
 
454
    return ('error', trace._qualified_exception_name(err.__class__, True),
 
455
        str(err))
452
456
 
453
457
 
454
458
class HelloRequest(SmartServerRequest):
501
505
    'Branch.set_tags_bytes', 'bzrlib.smart.branch',
502
506
    'SmartServerBranchSetTagsBytes')
503
507
request_handlers.register_lazy(
 
508
    'Branch.heads_to_fetch', 'bzrlib.smart.branch',
 
509
    'SmartServerBranchHeadsToFetch')
 
510
request_handlers.register_lazy(
504
511
    'Branch.get_stacked_on_url', 'bzrlib.smart.branch', 'SmartServerBranchRequestGetStackedOnURL')
505
512
request_handlers.register_lazy(
506
513
    'Branch.last_revision_info', 'bzrlib.smart.branch', 'SmartServerBranchRequestLastRevisionInfo')
510
517
    'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory')
511
518
request_handlers.register_lazy( 'Branch.set_config_option',
512
519
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOption')
 
520
request_handlers.register_lazy( 'Branch.set_config_option_dict',
 
521
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetConfigOptionDict')
513
522
request_handlers.register_lazy( 'Branch.set_last_revision',
514
523
    'bzrlib.smart.branch', 'SmartServerBranchRequestSetLastRevision')
515
524
request_handlers.register_lazy(