Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
bec280c6
Commit
bec280c6
authored
Aug 24, 2020
by
blitzmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some error handling
parent
6a8ae9c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
worker.py
cps/services/worker.py
+12
-6
No files found.
cps/services/worker.py
View file @
bec280c6
...
@@ -84,10 +84,8 @@ class WorkerThread(threading.Thread):
...
@@ -84,10 +84,8 @@ class WorkerThread(threading.Thread):
# sometimes tasks (like Upload) don't actually have work to do and are created as already finished
# sometimes tasks (like Upload) don't actually have work to do and are created as already finished
if
item
.
stat
is
STAT_WAITING
:
if
item
.
stat
is
STAT_WAITING
:
try
:
# CalibreTask.start() should wrap all exceptions in it's own error handling
item
.
start
(
self
)
item
.
start
(
self
)
except
Exception
as
e
:
log
.
exception
(
e
)
self
.
queue
.
task_done
()
self
.
queue
.
task_done
()
...
@@ -127,7 +125,14 @@ class CalibreTask:
...
@@ -127,7 +125,14 @@ class CalibreTask:
def
start
(
self
,
*
args
):
def
start
(
self
,
*
args
):
self
.
start_time
=
datetime
.
now
()
self
.
start_time
=
datetime
.
now
()
self
.
stat
=
STAT_STARTED
self
.
stat
=
STAT_STARTED
self
.
run
(
*
args
)
# catch any unhandled exceptions in a task and automatically fail it
try
:
self
.
run
(
*
args
)
except
Exception
as
e
:
self
.
_handleError
(
str
(
e
))
log
.
exception
(
e
)
self
.
end_time
=
datetime
.
now
()
self
.
end_time
=
datetime
.
now
()
@
property
@
property
...
@@ -144,7 +149,8 @@ class CalibreTask:
...
@@ -144,7 +149,8 @@ class CalibreTask:
@
progress
.
setter
@
progress
.
setter
def
progress
(
self
,
x
):
def
progress
(
self
,
x
):
# todo: throw error if outside of [0,1]
if
not
0
<=
x
<=
1
:
raise
ValueError
(
"Task progress should within [0, 1] range"
)
self
.
_progress
=
x
self
.
_progress
=
x
@
property
@
property
...
...
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