Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
esi-table-data
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esi-data-scrapping
esi-table-data
Commits
bffd2c64
Commit
bffd2c64
authored
Jun 16, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add functional for cancel job
parent
337bba66
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
service.py
esi/scraper/service.py
+8
-2
No files found.
esi/scraper/service.py
View file @
bffd2c64
from
datetime
import
datetime
from
scrapyd_api
import
ScrapydAPI
from
.models
import
Spider
,
Job
from
.models
import
Job
class
Service
:
...
...
@@ -20,9 +20,15 @@ class Service:
def
run_job
(
self
,
job
):
job
=
Job
.
objects
.
get
(
pk
=
job
)
print
(
job
.
spider
.
sp_name
)
uuid
=
self
.
api
.
schedule
(
'exa'
,
job
.
spider
.
sp_name
)
job
.
job_uuid
=
uuid
job
.
start_time
=
datetime
.
now
()
job
.
status
=
'RUN'
job
.
save
()
def
cancel_job
(
self
,
job
):
job
=
Job
.
objects
.
get
(
pk
=
job
)
self
.
api
.
cancel
(
'exa'
,
job
.
job_uuid
)
job
.
end_time
=
datetime
.
now
()
job
.
status
=
'FIN'
job
.
save
()
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