Revision bdefe5dd lib/utils.py
b/lib/utils.py | ||
---|---|---|
2156 | 2156 |
return (tsize, fsize) |
2157 | 2157 |
|
2158 | 2158 |
|
2159 |
def RunInSeparateProcess(fn): |
|
2159 |
def RunInSeparateProcess(fn, *args):
|
|
2160 | 2160 |
"""Runs a function in a separate process. |
2161 | 2161 |
|
2162 | 2162 |
Note: Only boolean return values are supported. |
2163 | 2163 |
|
2164 | 2164 |
@type fn: callable |
2165 | 2165 |
@param fn: Function to be called |
2166 |
@rtype: tuple of (int/None, int/None)
|
|
2167 |
@return: Exit code and signal number
|
|
2166 |
@rtype: bool
|
|
2167 |
@return: Function's result
|
|
2168 | 2168 |
|
2169 | 2169 |
""" |
2170 | 2170 |
pid = os.fork() |
... | ... | |
2175 | 2175 |
ResetTempfileModule() |
2176 | 2176 |
|
2177 | 2177 |
# Call function |
2178 |
result = int(bool(fn())) |
|
2178 |
result = int(bool(fn(*args)))
|
|
2179 | 2179 |
assert result in (0, 1) |
2180 | 2180 |
except: # pylint: disable-msg=W0702 |
2181 | 2181 |
logging.exception("Error while calling function in separate process") |
Also available in: Unified diff