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
daca3d40
Commit
daca3d40
authored
Jul 04, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added functional for running by specific time
parent
8427e299
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
settings.py
esi/esi/settings.py
+1
-1
tasks.py
esi/scraper/tasks.py
+19
-2
No files found.
esi/esi/settings.py
View file @
daca3d40
...
...
@@ -158,5 +158,5 @@ CELERY_BROKER_URL = 'amqp://guest:guest@localhost//'
CELERY_ACCEPT_CONTENT
=
[
'json'
]
CELERY_TASK_SERIALIZER
=
'json'
CELERY_RESULT_BACKEND
=
'rpc'
#
CELERY_RESULT_BACKEND = 'rpc'
CELERY_RESULT_PERSISTENT
=
True
esi/scraper/tasks.py
View file @
daca3d40
from
__future__
import
absolute_import
,
unicode_literals
from
celery
import
shared_task
from
.service
import
Service
from
.models
import
Job
@
shared_task
...
...
@@ -10,8 +11,24 @@ def add(x, y):
@
shared_task
def
run_job
(
job
):
def
run_job
(
job
_id
):
api
=
Service
()
print
(
'RUN spider'
)
api
.
run_job
(
job
)
job
=
Job
.
objects
.
get
(
pk
=
job_id
)
# run job nonstop
if
job
.
status
==
Job
.
FINISHED
and
job
.
interval
==
Job
.
NON
:
print
(
'NONSTOP'
)
api
.
run_job
(
job_id
)
# run job with some interval
elif
job
.
interval
and
job
.
interval
!=
Job
.
NON
:
print
(
'INTERVAL'
)
api
.
run_job
(
job_id
)
# run only one time
elif
job
.
status
==
Job
.
PENDING
and
not
job
.
interval
:
print
(
'ONE time'
)
api
.
run_job
(
job_id
)
job
.
schedule_job
.
delete
()
return
'spider was running'
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