Commit 071a3949 authored by Daniele Venzano's avatar Daniele Venzano
Browse files

Fix updating proxy access times

parent eb1f934e
...@@ -84,17 +84,21 @@ class ProxyManager: ...@@ -84,17 +84,21 @@ class ProxyManager:
for line in logf: for line in logf:
match = re.match(regex, line) match = re.match(regex, line)
if match is not None: if match is not None:
proxy_id = proxy_id = int(
timestamp = datetime.strptime(, "%d/%b/%Y:%H:%M:%S %z") timestamp = datetime.strptime(, "%d/%b/%Y:%H:%M:%S %z")
last_accesses[proxy_id] = timestamp last_accesses[proxy_id] = timestamp.replace(tzinfo=None)
state = AlchemySession() state = AlchemySession()
something_to_commit = False
for proxy in state.query(ProxyState).all(): for proxy in state.query(ProxyState).all():
if in last_accesses: if in last_accesses:
log.debug("Updating access timestamp for proxy ID {}".format(
proxy = state.query(ProxyState).filter_by( proxy = state.query(ProxyState).filter_by(
proxy.last_access = last_accesses[] if proxy.last_access != last_accesses[]:
log.debug("Updating access timestamp for proxy ID {}".format(
proxy.last_access = last_accesses[]
something_to_commit = True
proxy.container.cluster.execution.termination_notice = False proxy.container.cluster.execution.termination_notice = False
state.commit() if something_to_commit:
pm = ProxyManager() pm = ProxyManager()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment