Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Strand Lab
Strand Lab Cellxgene Gateway
Commits
b5158dee
Commit
b5158dee
authored
Sep 19, 2019
by
Alok Saldanha
Browse files
GH-4 properly reference cache.prune
also added logging
parent
f6d10946
Changes
1
Hide whitespace changes
Inline
Side-by-side
cellxgene_gateway/prune_process_cache.py
View file @
b5158dee
...
...
@@ -17,6 +17,7 @@ from cellxgene_gateway.env import ttl
class
PruneProcessCache
:
def
__init__
(
self
,
cache
):
self
.
cache
=
cache
self
.
expire_seconds
=
(
3600
if
ttl
is
None
else
int
(
ttl
))
def
__call__
(
self
):
while
True
:
...
...
@@ -25,16 +26,14 @@ class PruneProcessCache:
def
prune
(
self
):
timestamp
=
current_time_stamp
()
processes_to_delete
=
[]
for
p
in
self
.
cache
.
entry_list
:
if
timestamp
-
p
.
timestamp
>
(
3600
if
ttl
is
None
else
ttl
):
processes_to_delete
.
append
(
p
)
processes_to_delete
cutoff
=
timestamp
-
self
.
expire_seconds
processes_to_delete
=
[
p
for
p
in
self
.
cache
.
entry_list
if
p
.
timestamp
<
cutoff
]
processes_to_keep
=
[
p
for
p
in
self
.
cache
.
entry_list
if
not
p
.
timestamp
<
cutoff
]
logging
.
getLogger
(
"werkzeug"
).
debug
(
f
"Cutoff
{
cutoff
}
= timestamp
{
timestamp
}
- expire seconds
{
self
.
expire_seconds
}
, keeping
{
processes_to_keep
}
"
)
for
process
in
processes_to_delete
:
try
:
cache
.
prune
(
process
)
logging
.
getLogger
(
"werkzeug"
).
info
(
f
"pruning process
{
process
.
pid
}
(
{
process
.
dataset
}
)"
)
self
.
cache
.
prune
(
process
)
except
Exception
:
logging
.
getLogger
(
"werkzeug"
).
exception
(
"failed to prune process"
)
logging
.
getLogger
(
"werkzeug"
).
exception
(
"failed to prune process {process.pid} ({process.dataset})"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment