Revision 2b74ab4a kamaki/clients/__init__.py
b/kamaki/clients/__init__.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
from threading import Thread |
|
34 | 35 |
from json import dumps, loads |
35 | 36 |
from time import time |
36 | 37 |
import logging |
... | ... | |
68 | 69 |
self.details = details |
69 | 70 |
|
70 | 71 |
|
72 |
class SilentEvent(Thread): |
|
73 |
""" Thread-run method(*args, **kwargs) |
|
74 |
put exception in exception_bucket |
|
75 |
""" |
|
76 |
def __init__(self, method, *args, **kwargs): |
|
77 |
super(self.__class__, self).__init__() |
|
78 |
self.method = method |
|
79 |
self.args = args |
|
80 |
self.kwargs = kwargs |
|
81 |
|
|
82 |
@property |
|
83 |
def exception(self): |
|
84 |
return getattr(self, '_exception', False) |
|
85 |
|
|
86 |
@property |
|
87 |
def value(self): |
|
88 |
return getattr(self, '_value', None) |
|
89 |
|
|
90 |
def run(self): |
|
91 |
try: |
|
92 |
self._value = self.method(*(self.args), **(self.kwargs)) |
|
93 |
except Exception as e: |
|
94 |
print('______\n%s\n_______' % e) |
|
95 |
self._exception = e |
|
96 |
|
|
71 | 97 |
class Client(object): |
72 | 98 |
POOL_SIZE = 7 |
73 | 99 |
|
Also available in: Unified diff