Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: build/android/devil/utils/reraiser_thread.py

Issue 1396123002: reraiser_thread: Use func.__name__ for thread names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Thread and ThreadGroup that reraise exceptions on the main thread.""" 5 """Thread and ThreadGroup that reraise exceptions on the main thread."""
6 # pylint: disable=W0212 6 # pylint: disable=W0212
7 7
8 import logging 8 import logging
9 import sys 9 import sys
10 import threading 10 import threading
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 def __init__(self, func, args=None, kwargs=None, name=None): 43 def __init__(self, func, args=None, kwargs=None, name=None):
44 """Initialize thread. 44 """Initialize thread.
45 45
46 Args: 46 Args:
47 func: callable to call on a new thread. 47 func: callable to call on a new thread.
48 args: list of positional arguments for callable, defaults to empty. 48 args: list of positional arguments for callable, defaults to empty.
49 kwargs: dictionary of keyword arguments for callable, defaults to empty. 49 kwargs: dictionary of keyword arguments for callable, defaults to empty.
50 name: thread name, defaults to Thread-N. 50 name: thread name, defaults to Thread-N.
51 """ 51 """
52 if not name and func.__name__ != '<lambda>':
53 name = func.__name__
52 super(ReraiserThread, self).__init__(name=name) 54 super(ReraiserThread, self).__init__(name=name)
53 if not args: 55 if not args:
54 args = [] 56 args = []
55 if not kwargs: 57 if not kwargs:
56 kwargs = {} 58 kwargs = {}
57 self.daemon = True 59 self.daemon = True
58 self._func = func 60 self._func = func
59 self._args = args 61 self._args = args
60 self._kwargs = kwargs 62 self._kwargs = kwargs
61 self._ret = None 63 self._ret = None
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 Args: 219 Args:
218 funcs: List of functions to perform on their own threads. 220 funcs: List of functions to perform on their own threads.
219 watcher: Watchdog object providing timeout, by default waits forever. 221 watcher: Watchdog object providing timeout, by default waits forever.
220 222
221 Returns: 223 Returns:
222 A list of return values in the order of the given functions. 224 A list of return values in the order of the given functions.
223 """ 225 """
224 thread_group = ReraiserThreadGroup(ReraiserThread(f) for f in funcs) 226 thread_group = ReraiserThreadGroup(ReraiserThread(f) for f in funcs)
225 thread_group.StartAll(will_block=True) 227 thread_group.StartAll(will_block=True)
226 return thread_group.GetAllReturnValues(watcher=watcher) 228 return thread_group.GetAllReturnValues(watcher=watcher)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698