Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catching Errors when starting jobs #11

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Catching Errors when starting jobs
  • Loading branch information
vJan00 committed Dec 3, 2024
commit a9504a62be88ca5be3cddc52b93a0b5012a1b39b
51 changes: 27 additions & 24 deletions src/core/TsApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,33 @@ def ts_api_thread(self):
parallel_worker = int(os.environ.get("parallel_workers"))
if len(self.runningJobs) < parallel_worker:
if not self.queue.empty():
# Peek Job from Queue
uid: str
module_id: str
with self.queue.mutex:
uid, module_id = self.queue.queue[0][1]
self.runningJobs.append(uid)
# Checking module
if module_id:
# Opencast Module
if module_id in self.opencastModules:
logging.info("Preprocessing job with id " + uid
+ ".")
# ModuleID found
opencast_module: Opencast = self.opencastModules[
module_id]
opencast_module.download_file(uid)
opencast_module.queue_entry = (
opencast_module.queue_entry - 1)
# Change Status to prepared
database.change_job_status(uid, 1) # Prepared
try:
# Peek Job from Queue
uid: str
module_id: str
with self.queue.mutex:
uid, module_id = self.queue.queue[0][1]
self.runningJobs.append(uid)
# Checking module
if module_id:
# Opencast Module
if module_id in self.opencastModules:
logging.info("Preprocessing job with id " + uid
+ ".")
# ModuleID found
opencast_module: Opencast = self.opencastModules[
module_id]
opencast_module.download_file(uid)
opencast_module.queue_entry = (
opencast_module.queue_entry - 1)
# Change Status to prepared
database.change_job_status(uid, 1) # Prepared
# Register job
trans: Transcriber = self.register_job(uid)
# Start job
trans.start_thread()
except Exception:
pass
# Remove Job From Queue
self.queue.get()
# Register job
trans: Transcriber = self.register_job(uid)
# Start job
trans.start_thread()
time.sleep(5)
Loading