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

Merge pull request #2450 from nouiz/lock

Lock
...@@ -585,7 +585,7 @@ def debugprint(r, prefix='', depth=-1, done=None, print_type=False, ...@@ -585,7 +585,7 @@ def debugprint(r, prefix='', depth=-1, done=None, print_type=False,
already_printed = a in done # get_id_str put it in the dict already_printed = a in done # get_id_str put it in the dict
id_str = get_id_str(a) id_str = get_id_str(a)
if profile == None: if profile == None or a not in profile.apply_time:
if len(a.outputs) == 1: if len(a.outputs) == 1:
print >> file, '%s%s %s%s \'%s\' %s %s %s' % (prefix, a.op, print >> file, '%s%s %s%s \'%s\' %s %s %s' % (prefix, a.op,
id_str, id_str,
......
...@@ -97,6 +97,13 @@ def get_lock(lock_dir=None, **kw): ...@@ -97,6 +97,13 @@ def get_lock(lock_dir=None, **kw):
# every 'config.compile.timeout / 2' seconds to ensure # every 'config.compile.timeout / 2' seconds to ensure
# no one else tries to override our lock after their # no one else tries to override our lock after their
# 'config.compile.timeout' timeout period. # 'config.compile.timeout' timeout period.
if get_lock.start_time is None:
# This should not happen. So if this happen, clean up
# the lock state and raise an error.
while get_lock.n_lock > 0:
release_lock()
raise Exception("For some unknow reason, the lock was already taken,"
" but no start time was registered.")
now = time.time() now = time.time()
if now - get_lock.start_time > config.compile.timeout/2: if now - get_lock.start_time > config.compile.timeout/2:
lockpath = os.path.join(get_lock.lock_dir, 'lock') lockpath = os.path.join(get_lock.lock_dir, 'lock')
...@@ -320,7 +327,7 @@ def refresh_lock(lock_file): ...@@ -320,7 +327,7 @@ def refresh_lock(lock_file):
# from failing, we release the lock, but as there is a # from failing, we release the lock, but as there is a
# problem, we still keep the original exception. # problem, we still keep the original exception.
# This way, only 1 test would fail. # This way, only 1 test would fail.
while get_lock.lock_is_enabled: while get_lock.n_lock > 0:
release_lock() release_lock()
_logger.warn('Refreshing lock failed, we release the' _logger.warn('Refreshing lock failed, we release the'
' lock before raising again the exception') ' lock before raising again the exception')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论