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:
parent
edf9bda744
commit
8368754ba6
|
@ -26,8 +26,6 @@
|
||||||
``rattail.pyramid.views.batches.core`` -- Core Batch Views
|
``rattail.pyramid.views.batches.core`` -- Core Batch Views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import threading
|
|
||||||
|
|
||||||
from pyramid.httpexceptions import HTTPFound
|
from pyramid.httpexceptions import HTTPFound
|
||||||
from pyramid.renderers import render_to_response
|
from pyramid.renderers import render_to_response
|
||||||
|
|
||||||
|
@ -42,6 +40,7 @@ from edbob.pyramid.views import SearchableAlchemyGridView, CrudView, View
|
||||||
|
|
||||||
import rattail
|
import rattail
|
||||||
from rattail import batches
|
from rattail import batches
|
||||||
|
from rattail.threads import Thread
|
||||||
|
|
||||||
|
|
||||||
class BatchesGrid(SearchableAlchemyGridView):
|
class BatchesGrid(SearchableAlchemyGridView):
|
||||||
|
@ -165,7 +164,7 @@ class ExecuteBatch(View):
|
||||||
return HTTPFound(location=self.request.route_url('batches'))
|
return HTTPFound(location=self.request.route_url('batches'))
|
||||||
|
|
||||||
progress = SessionProgress(self.request.session, 'batch.execute')
|
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()
|
thread.start()
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'key': 'batch.execute',
|
'key': 'batch.execute',
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
``rattail.pyramid.views.products`` -- Product Views
|
``rattail.pyramid.views.products`` -- Product Views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import threading
|
|
||||||
|
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
from sqlalchemy.orm import joinedload
|
from sqlalchemy.orm import joinedload
|
||||||
|
|
||||||
|
@ -45,6 +43,7 @@ import rattail
|
||||||
import rattail.labels
|
import rattail.labels
|
||||||
from rattail import sil
|
from rattail import sil
|
||||||
from rattail import batches
|
from rattail import batches
|
||||||
|
from rattail.threads import Thread
|
||||||
from rattail.exceptions import LabelPrintingError
|
from rattail.exceptions import LabelPrintingError
|
||||||
from rattail.pyramid.forms import GPCFieldRenderer, PriceFieldRenderer
|
from rattail.pyramid.forms import GPCFieldRenderer, PriceFieldRenderer
|
||||||
|
|
||||||
|
@ -292,7 +291,7 @@ class CreateProductsBatch(ProductsGrid):
|
||||||
return HTTPFound(location=url)
|
return HTTPFound(location=url)
|
||||||
|
|
||||||
progress = SessionProgress(self.request.session, 'products.batch')
|
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()
|
thread.start()
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'key': 'products.batch',
|
'key': 'products.batch',
|
||||||
|
|
Loading…
Reference in a new issue