General purpose message pumping thread, that is used in many places.
Start the thread execution.
The thread will first call the self.Setup method with the parameters assigned by the eg.ThreadWorker constructor and waits till Setup() has finished its execution. If an exception is raised in self.Setup, this exception will be propagated to the self.Start method, so it will look like self.Start has directly called Setup(). But Setup() is actually executed in the new thread.
Call this if the thread should stop.
This will be called inside the thread at the beginning.
Any exception raised in this method will be propagated to the Start() method and re-raised there.
This will be called inside the thread when it finishes. It will even be called if the thread exits through an exception.
Queue a function and its arguments for execution in the eg.ThreadWorker thread. Doesn’t wait for the completion of the function.
Wraps a function for synchronized execution in the eg.ThreadWorker thread.
The returned object can be called like the unwrapped function but will execute in the eg.ThreadWorker thread regardless were it is called from. The call will deliver the return value of the function. If the function raises an exception, it will be propagated to the calling thread.
The optional timeout value specifies the maximal time to wait for the completion of the function in floating point seconds. If the timeout expires, the call will raise an exception. If timeout is not specified or None (the default), it will wait forever.
threadWorker = eg.ThreadWorker() threadWorker.Start() def MyFunction(param): print param return "Hello Caller!" wrappedFunc = threadWorker.Func(MyFunction, 5.0) result = wrappedFunc("Hello World!") print result
Queue a function for execution in the eg.ThreadWorker thread. Waits for completion of the function and returns its result.
The function must have no arguments, so if some are needed one should create a argumentless function with functools.partial.
This function is deprecated. Use the Func() wrapper instead.