Made batch creation and execution threads aware of sys.excepthook.

Updated both instances to use `rattail.threads.Thread` instead of
`threading.Thread`.  This way if an exception occurs within the
thread, the registered handler will be invoked.
This commit is contained in:
Lance Edgar 2013-02-20 22:08:40 -08:00
parent edf9bda744
commit 8368754ba6
2 changed files with 4 additions and 6 deletions

View file

@ -26,8 +26,6 @@
``rattail.pyramid.views.batches.core`` -- Core Batch Views
"""
import threading
from pyramid.httpexceptions import HTTPFound
from pyramid.renderers import render_to_response
@ -42,6 +40,7 @@ from edbob.pyramid.views import SearchableAlchemyGridView, CrudView, View
import rattail
from rattail import batches
from rattail.threads import Thread
class BatchesGrid(SearchableAlchemyGridView):
@ -165,7 +164,7 @@ class ExecuteBatch(View):
return HTTPFound(location=self.request.route_url('batches'))
progress = SessionProgress(self.request.session, 'batch.execute')
thread = threading.Thread(target=self.execute_batch, args=(batch, progress))
thread = Thread(target=self.execute_batch, args=(batch, progress))
thread.start()
kwargs = {
'key': 'batch.execute',

View file

@ -26,8 +26,6 @@
``rattail.pyramid.views.products`` -- Product Views
"""
import threading
from sqlalchemy import and_
from sqlalchemy.orm import joinedload
@ -45,6 +43,7 @@ import rattail
import rattail.labels
from rattail import sil
from rattail import batches
from rattail.threads import Thread
from rattail.exceptions import LabelPrintingError
from rattail.pyramid.forms import GPCFieldRenderer, PriceFieldRenderer
@ -292,7 +291,7 @@ class CreateProductsBatch(ProductsGrid):
return HTTPFound(location=url)
progress = SessionProgress(self.request.session, 'products.batch')
thread = threading.Thread(target=self.make_batch, args=(provider, progress))
thread = Thread(target=self.make_batch, args=(provider, progress))
thread.start()
kwargs = {
'key': 'products.batch',