File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 7
7
import inspect
8
8
import traceback
9
9
import pkg_resources
10
+ import imp
10
11
11
12
from diamond .util import load_class_from_name
12
13
from diamond .collector import Collector
@@ -151,9 +152,11 @@ def load_collectors_from_paths(paths):
151
152
152
153
modname = f [:- 3 ]
153
154
155
+ fp , pathname , description = imp .find_module (modname , [path ])
156
+
154
157
try :
155
158
# Import the module
156
- mod = __import__ (modname , globals (), locals (), [ '*' ] )
159
+ mod = imp . load_module (modname , fp , pathname , description )
157
160
except (KeyboardInterrupt , SystemExit ), err :
158
161
logger .error (
159
162
"System or keyboard interrupt "
@@ -170,6 +173,9 @@ def load_collectors_from_paths(paths):
170
173
else :
171
174
for name , cls in get_collectors_from_module (mod ):
172
175
collectors [name ] = cls
176
+ finally :
177
+ if fp :
178
+ fp .close ()
173
179
174
180
# Return Collector classes
175
181
return collectors
You can’t perform that action at this time.
0 commit comments