logging.debug('Job %s is running: pid=%s', row[0], row[1])
sys.exit(0)
- sqlexec(u'SELECT id, command, extension FROM job WHERE start_time IS NULL ORDER BY queue_time LIMIT 1')
+ sqlexec(u'SELECT id, command, extension, user_id FROM job WHERE start_time IS NULL ORDER BY queue_time LIMIT 1')
row = get_common_cursor().fetchone()
if row is None:
logging.debug('Queue is empty.')
sys.exit(0)
- jobid, command, extension = row
+ jobid, command, extension, user_id = row
logging.info('Starting job %s: %s', jobid, command)
sqlexec(u'UPDATE job SET start_time=now() WHERE id=%(jobid)s', {'jobid': jobid})
dbcommit()
logging.info('Job complete: result=%s', returncode)
+ sqlexec(u"INSERT INTO user_message (user_id, user_message_category_id, txt) VALUES(%(user_id)s, 'info', %(msg)s)", {'user_id':user_id, 'msg':'Your job %s is complete.' % jobid})
+ dbcommit()
+
if __name__ == '__main__':
main()