MCPcopy Index your code
hub / github.com/WebODM/WebODM / process_task

Function process_task

worker/tasks.py:129–173  ·  view source on GitHub ↗
(taskId)

Source from the content-addressed store, hash-verified

127
128@app.task(ignore_result=True, time_limit=settings.WORKERS_MAX_TIME_LIMIT)
129def process_task(taskId):
130 lock_id = 'task_lock_{}'.format(taskId)
131 cancel_monitor = None
132 delete_lock = True
133
134 try:
135 task_lock_last_update = redis_client.getset(lock_id, time.time())
136 if task_lock_last_update is not None:
137 # Check if lock has expired
138 if time.time() - float(task_lock_last_update) <= 30:
139 # Locked
140 delete_lock = False
141 return
142 else:
143 # Expired
144 logger.warning("Task {} has an expired lock! This could mean that WebODM is running out of memory. Check your server configuration.".format(taskId))
145
146 # Set lock
147 def update_lock():
148 redis_client.set(lock_id, time.time())
149 cancel_monitor = setInterval(5, update_lock)
150
151 try:
152 task = Task.objects.get(pk=taskId)
153 except ObjectDoesNotExist:
154 logger.info("Task {} has already been deleted.".format(taskId))
155 return
156
157 try:
158 task.process()
159 except Exception as e:
160 logger.error(
161 "Uncaught error while processing task {}. This is potentially bad. Please report it to http://github.com/WebODM/WebODM/issues: {} {}".format(
162 taskId, e, traceback.format_exc()))
163 if settings.TESTING: raise e
164 finally:
165 if cancel_monitor is not None:
166 cancel_monitor()
167
168 if delete_lock:
169 try:
170 redis_client.delete(lock_id)
171 except redis.exceptions.RedisError:
172 # Ignore errors, the lock will expire at some point
173 pass
174
175
176

Callers

nothing calls this directly

Calls 5

setIntervalFunction · 0.85
formatMethod · 0.45
getMethod · 0.45
processMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected