提交 f7553bee authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Pass logging levels to _rmtree, instead of function name as strings.

Also fix error that was causing compilation cache to fill up.
上级 061e875d
...@@ -28,7 +28,7 @@ def local_bitwidth(): ...@@ -28,7 +28,7 @@ def local_bitwidth():
return len('%x' % maxint) * 4 return len('%x' % maxint) * 4
_logger=logging.getLogger("theano.gof.cmodule") _logger=logging.getLogger("theano.gof.cmodule")
_logger.setLevel(logging.WARN) _logger.setLevel(logging.WARNING)
METH_VARARGS="METH_VARARGS" METH_VARARGS="METH_VARARGS"
METH_NOARGS="METH_NOARGS" METH_NOARGS="METH_NOARGS"
...@@ -536,7 +536,7 @@ class ModuleCache(object): ...@@ -536,7 +536,7 @@ class ModuleCache(object):
"without dll in cache, deleting it. %s", "without dll in cache, deleting it. %s",
key_pkl) key_pkl)
_rmtree(root, ignore_nocleanup=True, _rmtree(root, ignore_nocleanup=True,
msg="missing module file", level="info") msg="missing module file", level=logging.INFO)
continue continue
if (time_now - last_access_time(entry)) < age_thresh_use: if (time_now - last_access_time(entry)) < age_thresh_use:
_logger.debug('refresh adding %s', key_pkl) _logger.debug('refresh adding %s', key_pkl)
...@@ -551,14 +551,14 @@ class ModuleCache(object): ...@@ -551,14 +551,14 @@ class ModuleCache(object):
unpickle_failure() unpickle_failure()
_rmtree(root, ignore_nocleanup=True, _rmtree(root, ignore_nocleanup=True,
msg='broken cache directory [EOF]', msg='broken cache directory [EOF]',
level='warning') level=logging.WARNING)
continue continue
except Exception: except Exception:
unpickle_failure() unpickle_failure()
if delete_if_problem: if delete_if_problem:
_rmtree(root, ignore_nocleanup=True, _rmtree(root, ignore_nocleanup=True,
msg='broken cache directory', msg='broken cache directory',
level='info') level=logging.INFO)
else: else:
# This exception is often triggered by keys # This exception is often triggered by keys
# that contain references to classes that have # that contain references to classes that have
...@@ -597,7 +597,7 @@ class ModuleCache(object): ...@@ -597,7 +597,7 @@ class ModuleCache(object):
# This is suspicious. Better get rid of it. # This is suspicious. Better get rid of it.
_rmtree(root, ignore_nocleanup=True, _rmtree(root, ignore_nocleanup=True,
msg='module file path mismatch', msg='module file path mismatch',
level='info') level=logging.INFO)
continue continue
# Find unversioned keys from other processes. # Find unversioned keys from other processes.
...@@ -614,7 +614,7 @@ class ModuleCache(object): ...@@ -614,7 +614,7 @@ class ModuleCache(object):
'module %s', key_pkl) 'module %s', key_pkl)
_rmtree(root, ignore_nocleanup=True, _rmtree(root, ignore_nocleanup=True,
msg="unversioned key(s) in cache", msg="unversioned key(s) in cache",
level='info') level=logging.INFO)
continue continue
mod_hash = key_data.module_hash mod_hash = key_data.module_hash
...@@ -631,7 +631,7 @@ class ModuleCache(object): ...@@ -631,7 +631,7 @@ class ModuleCache(object):
if delete_if_problem or age > self.age_thresh_del: if delete_if_problem or age > self.age_thresh_del:
_rmtree(root, ignore_nocleanup=True, _rmtree(root, ignore_nocleanup=True,
msg='duplicated module', msg='duplicated module',
level='debug') level=logging.DEBUG)
else: else:
_logger.debug('Found duplicated module not ' _logger.debug('Found duplicated module not '
'old enough yet to be deleted ' 'old enough yet to be deleted '
...@@ -1025,7 +1025,7 @@ class ModuleCache(object): ...@@ -1025,7 +1025,7 @@ class ModuleCache(object):
assert entry not in self.module_from_name assert entry not in self.module_from_name
parent = os.path.dirname(entry) parent = os.path.dirname(entry)
assert parent.startswith(os.path.join(self.dirname, 'tmp')) assert parent.startswith(os.path.join(self.dirname, 'tmp'))
_rmtree(parent, msg='old cache directory', level='info', _rmtree(parent, msg='old cache directory', level=logging.INFO,
ignore_nocleanup=True) ignore_nocleanup=True)
finally: finally:
...@@ -1131,7 +1131,7 @@ class ModuleCache(object): ...@@ -1131,7 +1131,7 @@ class ModuleCache(object):
parent = os.path.dirname(entry) parent = os.path.dirname(entry)
assert parent.startswith(os.path.join(self.dirname, 'tmp')) assert parent.startswith(os.path.join(self.dirname, 'tmp'))
_rmtree(parent, msg='unversioned', level='info', _rmtree(parent, msg='unversioned', level=logging.INFO,
ignore_nocleanup=True) ignore_nocleanup=True)
# Sanity check: all unversioned keys should have been removed at # Sanity check: all unversioned keys should have been removed at
...@@ -1157,7 +1157,7 @@ class ModuleCache(object): ...@@ -1157,7 +1157,7 @@ class ModuleCache(object):
# take care of the clean-up. # take care of the clean-up.
if age > min_age: if age > min_age:
_rmtree(os.path.join(self.dirname, filename), _rmtree(os.path.join(self.dirname, filename),
msg='old unversioned', level='info', msg='old unversioned', level=logging.INFO,
ignore_nocleanup=True) ignore_nocleanup=True)
finally: finally:
compilelock.release_lock() compilelock.release_lock()
...@@ -1173,7 +1173,7 @@ class ModuleCache(object): ...@@ -1173,7 +1173,7 @@ class ModuleCache(object):
_logger.debug('Time spent checking keys: %s', _logger.debug('Time spent checking keys: %s',
self.time_spent_in_check_key) self.time_spent_in_check_key)
def _rmtree(parent, ignore_nocleanup=False, msg='', level='debug', def _rmtree(parent, ignore_nocleanup=False, msg='', level=logging.DEBUG,
ignore_if_missing=False): ignore_if_missing=False):
# On NFS filesystems, it is impossible to delete a directory with open # On NFS filesystems, it is impossible to delete a directory with open
# files in it. So instead, some commands in this file will respond to a # files in it. So instead, some commands in this file will respond to a
...@@ -1186,10 +1186,12 @@ def _rmtree(parent, ignore_nocleanup=False, msg='', level='debug', ...@@ -1186,10 +1186,12 @@ def _rmtree(parent, ignore_nocleanup=False, msg='', level='debug',
log_msg = 'Deleting' log_msg = 'Deleting'
if msg: if msg:
log_msg += ' (%s)' % msg log_msg += ' (%s)' % msg
eval(level)('%s: %s' % (log_msg, parent)) _logger.log(level, '%s: %s', log_msg, parent)
shutil.rmtree(parent) shutil.rmtree(parent)
except Exception, e: except Exception, e:
# If parent still exists, mark it for deletion by a future refresh() # If parent still exists, mark it for deletion by a future refresh()
_logger.debug('In _rmtree, encountered exception: %s(%s)',
type(e), e)
if os.path.exists(parent): if os.path.exists(parent):
try: try:
_logger.info('placing "delete.me" in %s', parent) _logger.info('placing "delete.me" in %s', parent)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论