Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gerion Entrup
brainzfs
Commits
385db906
Commit
385db906
authored
Sep 26, 2016
by
Gerion Entrup
Browse files
caching: add globals for global caching structure
parent
50531464
Changes
1
Hide whitespace changes
Inline
Side-by-side
globals.py
0 → 100644
View file @
385db906
import
sqlalchemy
import
threading
dirty_table
=
{}
dirty_table_lock
=
threading
.
RLock
()
def
is_dirty
(
table
):
global
dirty_table
global
dirty_table_lock
with
dirty_table_lock
:
try
:
return
dirty_table
[
table
]
except
KeyError
:
dirty_table
[
table
]
=
False
return
False
def
set_dirty
(
table
,
value
=
True
):
global
dirty_table
global
dirty_table_lock
if
type
(
table
)
is
sqlalchemy
.
ext
.
declarative
.
api
.
DeclarativeMeta
:
table
=
table
.
__tablename__
with
dirty_table_lock
:
dirty_table
[
table
]
=
value
Write
Preview
Supports
Markdown
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