Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
5
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
32dfeb71
authored
Jan 23, 2022
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Abortable task fix
parent
673168ca
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
circle/storage/models.py
+10
-8
No files found.
circle/storage/models.py
View file @
32dfeb71
...
@@ -21,9 +21,11 @@
...
@@ -21,9 +21,11 @@
import
logging
import
logging
import
uuid
import
uuid
import
time
import
re
import
re
from
celery.contrib.abortable
import
AbortableAsyncResult
from
celery.contrib.abortable
import
AbortableAsyncResult
from
celery.result
import
allow_join_result
from
celery.exceptions
import
TimeoutError
from
celery.exceptions
import
TimeoutError
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.urls
import
reverse
from
django.urls
import
reverse
...
@@ -433,15 +435,15 @@ class Disk(TimeStampedModel):
...
@@ -433,15 +435,15 @@ class Disk(TimeStampedModel):
@classmethod
@classmethod
def
_run_abortable_task
(
cls
,
remote
,
task
):
def
_run_abortable_task
(
cls
,
remote
,
task
):
while
True
:
while
not
remote
.
ready
():
try
:
time
.
sleep
(
5
)
result
=
remote
.
get
(
timeout
=
5
)
logger
.
debug
(
"Waiting for abortable task. Status:
%
s"
,
AbortableAsyncResult
(
remote
.
id
)
.
status
)
break
except
TimeoutError
as
e
:
if
task
is
not
None
and
task
.
is_aborted
():
if
task
is
not
None
and
task
.
is_aborted
():
AbortableAsyncResult
(
remote
.
id
)
.
abort
()
AbortableAsyncResult
(
remote
.
id
)
.
abort
()
raise
humanize_exception
(
ugettext_noop
(
raise
humanize_exception
(
ugettext_noop
(
"Operation aborted by user."
),
TimeoutError
(
"Abort"
))
"Operation aborted by user."
),
e
)
with
allow_join_result
():
result
=
remote
.
get
()
return
result
return
result
@classmethod
@classmethod
...
@@ -472,7 +474,7 @@ class Disk(TimeStampedModel):
...
@@ -472,7 +474,7 @@ class Disk(TimeStampedModel):
result
=
cls
.
_run_abortable_task
(
remote
,
task
)
result
=
cls
.
_run_abortable_task
(
remote
,
task
)
disk
.
size
=
result
[
'size'
]
disk
.
size
=
result
[
'size'
]
disk
.
type
=
result
[
'type'
]
disk
.
type
=
result
[
'type'
]
disk
.
checksum
=
result
.
get
(
'checksum'
,
None
)
disk
.
checksum
=
result
[
'checksum'
]
disk
.
is_ready
=
True
disk
.
is_ready
=
True
disk
.
save
()
disk
.
save
()
return
disk
return
disk
...
...
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