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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
circle/storage/models.py
+12
-10
No files found.
circle/storage/models.py
View file @
32dfeb71
...
...
@@ -21,9 +21,11 @@
import
logging
import
uuid
import
time
import
re
from
celery.contrib.abortable
import
AbortableAsyncResult
from
celery.result
import
allow_join_result
from
celery.exceptions
import
TimeoutError
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.urls
import
reverse
...
...
@@ -433,15 +435,15 @@ class Disk(TimeStampedModel):
@classmethod
def
_run_abortable_task
(
cls
,
remote
,
task
):
while
True
:
t
ry
:
result
=
remote
.
get
(
timeout
=
5
)
break
except
TimeoutError
as
e
:
if
task
is
not
None
and
task
.
is_aborted
():
AbortableAsyncResult
(
remote
.
id
)
.
abort
()
raise
humanize_exception
(
ugettext_noop
(
"Operation aborted by user."
),
e
)
while
not
remote
.
ready
()
:
t
ime
.
sleep
(
5
)
logger
.
debug
(
"Waiting for abortable task. Status:
%
s"
,
AbortableAsyncResult
(
remote
.
id
)
.
status
)
if
task
is
not
None
and
task
.
is_aborted
():
AbortableAsyncResult
(
remote
.
id
)
.
abort
()
raise
humanize_exception
(
ugettext_noop
(
"Operation aborted by user."
),
TimeoutError
(
"Abort"
))
with
allow_join_result
():
result
=
remote
.
get
(
)
return
result
@classmethod
...
...
@@ -472,7 +474,7 @@ class Disk(TimeStampedModel):
result
=
cls
.
_run_abortable_task
(
remote
,
task
)
disk
.
size
=
result
[
'size'
]
disk
.
type
=
result
[
'type'
]
disk
.
checksum
=
result
.
get
(
'checksum'
,
None
)
disk
.
checksum
=
result
[
'checksum'
]
disk
.
is_ready
=
True
disk
.
save
()
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