Package Camelot :: Package camelot :: Package view :: Package model_thread :: Module no_thread_model_thread |
[frames] | no frames]

# Source Code for Module Camelot.camelot.view.model_thread.no_thread_model_thread

     1  '''
     2  Created on Sep 12, 2009
     3
     4  @author: tw55413
     5  '''
     6
     7  import logging
     8  logger = logging.getLogger('camelot.view.model_thread.no_thread_model_thread')
     9
    10  from PyQt4 import QtCore
    11  from signal_slot_model_thread import AbstractModelThread, setup_model
    12
    13 -class NoThreadModelThread(QtCore.QObject, AbstractModelThread):
    14
    15 -    def __init__(self, setup_thread = setup_model ):
    16          QtCore.QObject.__init__(self)
    17          self.responses = []
    18          AbstractModelThread.__init__(self, setup_thread = setup_model )
    19          self._setup_thread()
    20
    21 -    def start(self):
    22          pass
    23
    24 -    def post( self, request, response = None, exception = None ):
    25          try:
    26              result = request()
    27              response( result )
    28          except Exception, e:
    29              if exception:
    30                  logger.error( 'exception caught in model thread while executing %s'%self._name, exc_info = e )
    31                  import traceback, cStringIO
    32                  sio = cStringIO.StringIO()
    33                  traceback.print_exc(file=sio)
    34                  traceback_print = sio.getvalue()
    35                  sio.close()
    36                  exception_info = (e, traceback_print)
    37                  exception(exception_info)
    38
    39 -    def wait_on_work(self):
    40          app = QtCore.QCoreApplication.instance()
    41          while app.hasPendingEvents():
    42              app.processEvents()
    43
    44 -    def isRunning(self):
    45          return True
    46