camelot.camelot.view.model_thread.ModelThread

Package camelot :: Package camelot :: Package view :: Module model_thread :: Class ModelThread |
[hide private]
[frames] | no frames]

# Class ModelThread

source code

Thread in which the model runs, all requests to the model should be posted to the the model thread.

This class ensures the gui thread doesn't block when the model needs time to complete tasks by providing asynchronous communication between the model thread and the gui thread

Instance Methods | [hide private]
__init__(self, response_signaler) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code
run(self) | source code
process_responses(self) Process all responses that are generated by completed requests from the ModelThread. | source code
post(self, request, response=lambda result: None, exception=lambda exc: None) Post a request to the model thread, request should be a function that takes no arguments. | source code
post_and_block(self, request) Post a request tot the model thread, block until it is finished, and then return it results. | source code
Inherited from `threading.Thread`: `__repr__`, `getName`, `isAlive`, `isDaemon`, `join`, `setDaemon`, `setName`, `start` Inherited from `threading.Thread` (private): `_set_daemon` Inherited from `threading._Verbose` (private): `_note` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, response_signaler) (Constructor) | source code
x.__init__(...) initializes x; see x.__class__.__doc__ for signature Parameters: `response_signaler` - an object with methods called : responseAvailable() : this method will be called when a response is available startProcessingRequest(), stopProcessingRequest(), Overrides: object.__init__

### run(self) | source code
Overrides: threading.Thread.run

### process_responses(self) | source code
Process all responses that are generated by completed requests from the ModelThread. This method should be called from time to time from within the GUI thread.

### post(self, request, response=lambda result: None, exception=lambda exc: None) | source code
Post a request to the model thread, request should be a function that takes no arguments. The request function will be called within the model thread. When the request is finished, on first occasion, the response function will be called within the gui thread. The response function takes as arguments, the results of the request function. Parameters: `request` - function to be called within the model thread `response` - function to be called within the gui thread, when the request function is finished, the response function takes as its argument the result of the request function `exception` - function to be called in case of an exception in the request function @return a threading Event object which will be set to True when the request function is finished and the response has been put on the queue

### post_and_block(self, request) | source code
Post a request tot the model thread, block until it is finished, and then return it results. This function only exists for testing purposes, it should never be used from within the gui thread