File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 22import tempfile
33import whisper
44import sqlite3
5+ from threading import Lock
6+ import os
57from threading import Thread
68from datetime import datetime
79import json
1113
1214
1315# Create jobs database if it doesn't exist
16+ def get_db_connection ():
17+ conn = sqlite3 .connect (
18+ "jobs.db" ,
19+ check_same_thread = False ,
20+ timeout = 30 , # 30 second timeout
21+ )
22+ conn .row_factory = sqlite3 .Row
23+ return conn
24+
25+
1426def init_db ():
15- conn = sqlite3 .connect ("jobs.db" )
27+ conn = get_db_connection ()
28+ c = conn .cursor ()
1629 c = conn .cursor ()
1730 c .execute ("""
1831 CREATE TABLE IF NOT EXISTS jobs (
@@ -36,7 +49,7 @@ def init_db():
3649def process_job (job_id ):
3750 # Create app context for the thread
3851 with app .app_context ():
39- conn = sqlite3 . connect ( "jobs.db" )
52+ conn = get_db_connection ( )
4053 c = conn .cursor ()
4154
4255 # Get job details
@@ -153,7 +166,7 @@ def start_transcription():
153166
154167@app .route ("/status/<job_id>" , methods = ["GET" ])
155168def get_job_status (job_id ):
156- conn = sqlite3 . connect ( "jobs.db" )
169+ conn = get_db_connection ( )
157170 c = conn .cursor ()
158171
159172 c .execute (
You can’t perform that action at this time.
0 commit comments