Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9406a057
authored
Feb 14, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: move concurrent activity checking to ctor methods
parent
054e4941
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
circle/vm/models/activity.py
+14
-14
No files found.
circle/vm/models/activity.py
View file @
9406a057
...
...
@@ -47,6 +47,11 @@ class InstanceActivity(ActivityModel):
@classmethod
def
create
(
cls
,
code_suffix
,
instance
,
task_uuid
=
None
,
user
=
None
):
# Check for concurrent activities
active_activities
=
instance
.
activity_log
.
filter
(
finished__isnull
=
True
)
if
active_activities
.
exists
():
raise
ActivityInProgressError
(
active_activities
[
0
])
act
=
cls
(
activity_code
=
'vm.Instance.'
+
code_suffix
,
instance
=
instance
,
parent
=
None
,
resultant_state
=
None
,
started
=
timezone
.
now
(),
task_uuid
=
task_uuid
,
user
=
user
)
...
...
@@ -54,6 +59,11 @@ class InstanceActivity(ActivityModel):
return
act
def
create_sub
(
self
,
code_suffix
,
task_uuid
=
None
):
# Check for concurrent activities
active_children
=
self
.
children
.
filter
(
finished__isnull
=
True
)
if
active_children
.
exists
():
raise
ActivityInProgressError
(
active_children
[
0
])
act
=
InstanceActivity
(
activity_code
=
self
.
activity_code
+
'.'
+
code_suffix
,
instance
=
self
.
instance
,
parent
=
self
,
resultant_state
=
None
,
...
...
@@ -64,28 +74,18 @@ class InstanceActivity(ActivityModel):
@contextmanager
def
sub_activity
(
self
,
code_suffix
,
on_abort
=
None
,
on_commit
=
None
,
task_uuid
=
None
):
# Check for concurrent activities
active_children
=
self
.
children
.
filter
(
finished__isnull
=
True
)
if
active_children
.
exists
():
raise
ActivityInProgressError
(
active_children
[
0
])
"""Create a transactional context for a nested instance activity.
"""
act
=
self
.
create_sub
(
code_suffix
,
task_uuid
)
return
activitycontextimpl
(
act
,
on_abort
=
on_abort
,
on_commit
=
on_commit
)
@contextmanager
def
instance_activity
(
code_suffix
,
instance
,
on_abort
=
None
,
on_commit
=
None
,
task_uuid
=
None
,
user
=
None
):
# Check for concurrent activities
active_activities
=
instance
.
activity_log
.
filter
(
finished__isnull
=
True
)
if
active_activities
.
exists
():
raise
ActivityInProgressError
(
active_activities
[
0
])
"""Create a transactional context for an instance activity.
"""
act
=
InstanceActivity
.
create
(
code_suffix
,
instance
,
task_uuid
,
user
)
return
activitycontextimpl
(
act
,
on_abort
=
on_abort
,
on_commit
=
on_commit
)
...
...
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