Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
2f6508fe
Commit
2f6508fe
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
tests passing for v2.0.24
parent
6a24aea8
No related branches found
Branches containing commit
Tags
v2.0.24
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
satella/coding/concurrent/locked_dataset.py
+5
-1
5 additions, 1 deletion
satella/coding/concurrent/locked_dataset.py
satella/coding/fun_static.py
+16
-0
16 additions, 0 deletions
satella/coding/fun_static.py
tests/test_coding/test_fun_static.py
+2
-1
2 additions, 1 deletion
tests/test_coding/test_fun_static.py
with
23 additions
and
2 deletions
satella/coding/concurrent/locked_dataset.py
+
5
−
1
View file @
2f6508fe
...
...
@@ -3,6 +3,7 @@ import typing
import
threading
import
inspect
import
functools
import
six
from
...exceptions
import
ResourceLocked
,
ResourceNotLocked
...
...
@@ -70,7 +71,10 @@ class LockedDataset(object):
return
super
(
LockedDataset
,
self
).
__setattr__
(
key
,
value
)
def
__call__
(
self
,
blocking
=
True
,
timeout
=-
1
):
get_internal
(
self
).
args
=
(
blocking
,
timeout
)
if
six
.
PY2
:
get_internal
(
self
).
args
=
blocking
,
else
:
get_internal
(
self
).
args
=
blocking
,
timeout
return
self
def
__enter__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
satella/coding/fun_static.py
+
16
−
0
View file @
2f6508fe
...
...
@@ -6,6 +6,22 @@ logger = logging.getLogger(__name__)
def
static_var
(
var_name
,
value
):
"""
Declare a static variable for given function
Use it like:
@static_var(
'
counter
'
, 2)
def count():
count.counter += 1
or (syntax valid only on Python 3)
class MyClass:
@static_var(
'
counter
'
, 2)
def count():
MyClass.counter += 1
"""
def
decorate
(
func
):
setattr
(
func
,
var_name
,
value
)
return
func
...
...
This diff is collapsed.
Click to expand it.
tests/test_coding/test_fun_static.py
+
2
−
1
View file @
2f6508fe
import
unittest
from
threading
import
Thread
from
time
import
sleep
import
six
from
six.moves.queue
import
Queue
from
satella.coding
import
static_var
...
...
@@ -18,6 +18,7 @@ class FunTestTest(unittest.TestCase):
static_fun
(
3
)
self
.
assertEquals
(
static_fun
.
counter
,
4
)
@unittest.skipIf
(
six
.
PY2
,
'
Syntax unsupported on Python 2
'
)
def
test_fun_static_method
(
self
):
class
MyClass
(
object
):
@static_var
(
"
counter
"
,
2
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment