Skip to content
Snippets Groups Projects
Commit 15319b1c authored by Joseph Weston's avatar Joseph Weston
Browse files

remove reference to app context from 'process_pdf'

This makes 'process_pdf' easier to use from a Python shell, which
helps with debugging
parent 41d6740b
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,6 @@ import pandas
import cv2
import zbar
from flask import current_app as app
from pony import orm
from . import yaml_helper
......@@ -25,7 +24,7 @@ ExamMetadata = namedtuple('ExamMetadata',
['version', 'exam_name', 'qr_coords', 'widget_data'])
def process_pdf(pdf_id):
def process_pdf(pdf_id, data_directory):
"""Process a PDF, recording progress to a database
This *must* be called from a subprocess of the
......@@ -36,9 +35,9 @@ def process_pdf(pdf_id):
----------
pdf_id : int
The ID in the database of the PDF to process
data_directory : str
The absolute path to the data directory on disk
"""
data_directory = app.config['DATA_DIRECTORY']
report_error = functools.partial(write_pdf_status, pdf_id, 'error')
report_progress = functools.partial(write_pdf_status, pdf_id, 'processing')
report_success = functools.partial(write_pdf_status, pdf_id, 'success')
......
......@@ -76,7 +76,8 @@ class Pdfs(Resource):
# TODO: save these into a process-local datastructure, or save
# it into the DB as well so that we can cull 'processing' tasks
# that are actually dead.
Process(target=pdf_helper.process_pdf, args=(pdf.id,)).start()
args = (pdf.id, app.config['DATA_DIRECTORY'])
Process(target=pdf_helper.process_pdf, args=args).start()
return {
'id': pdf.id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment