General purpose message pumping thread, that is used in many places.
Call(func, *args, **kwargs)¶
Queue a function and its arguments for execution in the
eg.ThreadWorkerthread. Doesn’t wait for the completion of the function.
Queue a function for execution in the
eg.ThreadWorkerthread. 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
This will be called inside the thread when it finishes. It will even be called if the thread exits through an exception.
Wraps a function for synchronized execution in the
The returned object can be called like the unwrapped function but will execute in the
eg.ThreadWorkerthread 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
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.
Start the thread execution.
The thread will first call the self.Setup method with the parameters assigned by the
eg.ThreadWorkerconstructor 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()is actually executed in the new thread.
Call this if the thread should stop.