/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 breezy/cethread.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
        super(CatchingExceptionThread, self).__init__(*args, **kwargs)
45
45
        self.set_sync_event(sync_event)
46
46
        self.exception = None
47
 
        self.ignored_exceptions = None  # see set_ignored_exceptions
 
47
        self.ignored_exceptions = None # see set_ignored_exceptions
48
48
        self.lock = threading.Lock()
49
49
 
50
50
    def set_sync_event(self, event):
85
85
        """
86
86
        cur = self.sync_event
87
87
        self.lock.acquire()
88
 
        try:  # Always release the lock
 
88
        try: # Always release the lock
89
89
            try:
90
90
                self.set_sync_event(new)
91
91
                # From now on, any exception will be synced with the new event
92
 
            except BaseException:
 
92
            except:
93
93
                # Unlucky, we couldn't set the new sync event, try restoring a
94
94
                # safe state
95
95
                self.set_sync_event(cur)
105
105
        """Declare which exceptions will be ignored.
106
106
 
107
107
        :param ignored: Can be either:
108
 
 
 
108
        
109
109
           - None: all exceptions will be raised,
110
110
           - an exception class: the instances of this class will be ignored,
111
111
           - a tuple of exception classes: the instances of any class of the
126
126
        try:
127
127
            try:
128
128
                super(CatchingExceptionThread, self).run()
129
 
            except BaseException:
 
129
            except:
130
130
                self.exception = sys.exc_info()
131
131
        finally:
132
132
            # Make sure the calling thread is released
133
133
            self.sync_event.set()
134
134
 
 
135
 
135
136
    def join(self, timeout=None):
136
137
        """Overrides Thread.join to raise any exception caught.
137
138
 
141
142
        super(CatchingExceptionThread, self).join(timeout)
142
143
        if self.exception is not None:
143
144
            exc_class, exc_value, exc_tb = self.exception
144
 
            self.exception = None  # The exception should be raised only once
 
145
            self.exception = None # The exception should be raised only once
145
146
            if (self.ignored_exceptions is None
146
 
                    or not self.ignored_exceptions(exc_value)):
 
147
                or not self.ignored_exceptions(exc_value)):
147
148
                # Raise non ignored exceptions
148
149
                reraise(exc_class, exc_value, exc_tb)
149
150