def blog_publish(blog_id): user = auth.is_logged_in(request) blog = Blog.load(blog_id) permission = auth.is_blog_publisher(user, blog) queue_length = Queue.job_counts(blog=blog) if queue_length > 0: start_message = template('queue/queue_run_include', queue=Queue.jobs(blog), percentage_complete=0, blog=blog, break_path='{}/blog/{}/publish/break'.format( BASE_URL, blog.id)) Queue.start(blog, queue_length) else: start_message = "Queue empty." tags = template_tags(blog_id=blog.id, user=user) # return template( 'queue/queue_run_ui', start=queue_length, start_message=start_message, action_url="../../blog/{}/publish/progress/{}".format( blog.id, queue_length), title='Publishing queue progress', # search_context=(search_context['blog_queue'], blog), menu=generate_menu('blog_queue', blog), **tags.__dict__)
def blog_publish(blog_id): user = auth.is_logged_in(request) blog = Blog.load(blog_id) permission = auth.is_blog_publisher(user, blog) queue_length = Queue.job_counts(blog=blog) if queue_length > 0: start_message = template('queue/queue_run_include', queue=Queue.jobs(blog), percentage_complete=0, blog=blog, break_path='{}/blog/{}/publish/break'.format(BASE_URL, blog.id) ) Queue.start(blog, queue_length) else: start_message = "Queue empty." tags = template_tags(blog_id=blog.id, user=user) # return template('queue/queue_run_ui', start=queue_length, start_message=start_message, action_url="../../blog/{}/publish/progress/{}".format(blog.id, queue_length), title='Publishing queue progress', # search_context=(search_context['blog_queue'], blog), menu=generate_menu('blog_queue', blog), **tags.__dict__)
def process_queue(blog): ''' Processes the jobs currently in the queue for the selected blog. ''' queue_control = Queue.acquire(blog, True) if queue_control is None: return 0 if queue_control.job_type == job_type.control: process_queue_publish(queue_control, blog) elif queue_control.job_type == job_type.insert: process_queue_insert(queue_control, blog) return Queue.job_counts(blog=blog)
with db.atomic() as txn: scheduled_page_report.append('{} -- on {}'.format(p.title, p.publication_date)) p.status = page_status.published p.save(p.user, no_revision=True) queue_page_actions((p,)) blogs_to_check[p.blog.id] = p.blog except Exception as e: problem = 'Problem with page {}: {}'.format(n.title, e) print (problem) scheduled_page_report.append(problem) queue_index_actions(n) queue_ssi_actions(n) waiting = Queue.job_counts(blog=n) waiting_report = '{} jobs waiting for blog {}'.format(waiting, n.id) print (waiting_report) scheduled_page_report.append(waiting_report) Queue.start(n) print ("Processing {} jobs for blog '{}'.".format( waiting, n.name)) from time import clock begin = clock() passes = 1 while 1:
scheduled_page_report.append('{} -- on {}'.format( p.title, p.publication_date)) p.status = page_status.published p.save(p.user, no_revision=True) queue_page_actions((p, )) blogs_to_check[p.blog.id] = p.blog except Exception as e: problem = 'Problem with page {}: {}'.format(n.title, e) print(problem) scheduled_page_report.append(problem) queue_index_actions(n) queue_ssi_actions(n) waiting = Queue.job_counts(blog=n) waiting_report = '{} jobs waiting for blog {}'.format( waiting, n.id) print(waiting_report) scheduled_page_report.append(waiting_report) Queue.start(n) print("Processing {} jobs for blog '{}'.".format( waiting, n.name)) from time import clock begin = clock() passes = 1