Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
0x43
eBookHub-backend
Commits
49cec21b
Commit
49cec21b
authored
Mar 16, 2019
by
Patrick van der Leer
Browse files
Fixes background scheduler/blackhole processor
parent
74d7af4f
Pipeline
#313
passed with stage
in 4 minutes and 36 seconds
Changes
4
Pipelines
6
Hide whitespace changes
Inline
Side-by-side
eBookHub/__init__.py
View file @
49cec21b
...
...
@@ -120,6 +120,7 @@ def configure_scheduler(app): # pragma: no cover
ext
.
scheduler
.
add_job
(
func
=
process_blackhole_job
,
kwargs
=
{
"app"
:
app
,
"blackhole_path"
:
app
.
config
[
'BLACKHOLE_PATH'
]
},
trigger
=
"interval"
,
...
...
@@ -129,7 +130,6 @@ def configure_scheduler(app): # pragma: no cover
except
Exception
as
e
:
app
.
logger
.
error
(
str
(
e
))
raise
ext
.
scheduler
.
start
()
...
...
eBookHub/jobs/blackhole.py
View file @
49cec21b
...
...
@@ -151,9 +151,10 @@ def process_blackhole(blackhole_path):
yield
saved
,
book_edition_file
,
file
def
process_blackhole_job
(
blackhole_path
):
def
process_blackhole_job
(
app
,
blackhole_path
):
if
lock
.
acquire
(
blocking
=
False
):
list
(
process_blackhole
(
os
.
path
.
abspath
(
blackhole_path
)))
with
app
.
app_context
():
list
(
process_blackhole
(
os
.
path
.
abspath
(
blackhole_path
)))
__all__
=
(
...
...
eBookHub/scheduler.py
View file @
49cec21b
...
...
@@ -11,7 +11,7 @@ class Scheduler(BackgroundScheduler):
atexit
.
register
(
lambda
:
self
.
shutdown
())
def
start
(
self
,
*
args
,
**
kwargs
):
if
self
.
_thread
and
not
self
.
_thread
.
is_alive
():
if
not
self
.
_thread
or
not
self
.
_thread
.
is_alive
():
super
().
start
(
*
args
,
**
kwargs
)
def
shutdown
(
self
,
*
args
,
**
kwargs
):
...
...
tests/test_blackhole.py
View file @
49cec21b
...
...
@@ -16,4 +16,4 @@ class BlackHoleTestCase(MyTestCase, TestCase):
with
open
(
path
,
"w+"
)
as
f
:
f
.
write
(
"1234"
)
process_blackhole_job
(
get_blackhole_path
())
process_blackhole_job
(
self
.
app
,
get_blackhole_path
())
Write
Preview
Supports
Markdown
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