Skip to content

Commit

Permalink
bugfix: since transcriber.transcribe runs in a thread, we need to syn…
Browse files Browse the repository at this point in the history
…chronously create the outdir and copy over view_alignment before issuing the redirect
  • Loading branch information
Robert M Ochshorn authored and Robert M Ochshorn committed Feb 28, 2016
1 parent 5217583 commit 9250042
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ def save():
with open(os.path.join(outdir, 'align.csv'), 'w') as csvfile:
csvfile.write(to_csv(output))

outdir = os.path.join(self.data_dir, 'transcriptions', uid)
os.makedirs(outdir)

# Copy over the HTML
shutil.copy(get_resource('www/view_alignment.html'), os.path.join(outdir, 'index.html'))
outdir = os.path.join(self.data_dir, 'transcriptions', uid)

tran_path = os.path.join(outdir, 'transcript.txt')
with open(tran_path, 'w') as tranfile:
Expand Down Expand Up @@ -167,6 +163,15 @@ def render_POST(self, req):
if 'async' in req.args and req.args['async'][0] == 'false':
async = False

# We need to make the transcription directory here, so that
# when we redirect the user we are sure that there's a place
# for them to go.
outdir = os.path.join(self.transcriber.data_dir, 'transcriptions', uid)
os.makedirs(outdir)

# Copy over the HTML
shutil.copy(get_resource('www/view_alignment.html'), os.path.join(outdir, 'index.html'))

result_promise = threads.deferToThreadPool(
self.reactor, self.reactor.getThreadPool(),
self.transcriber.transcribe,
Expand Down

0 comments on commit 9250042

Please sign in to comment.