'get' will block until the processed function returns, timeout happens, or the work is cancelled. You can test if you were cancelled by the isCancelled() method, and you can test if you reached the timeout by the isAlive() method. Notice, cancelling w
(self, timeout=None)
| 119 | ############################################################################ |
| 120 | |
| 121 | def get (self, timeout=None): |
| 122 | """ 'get' will block until the processed function returns, timeout |
| 123 | happens, or the work is cancelled. |
| 124 | You can test if you were cancelled by the isCancelled() method, and |
| 125 | you can test if you reached the timeout by the isAlive() method. |
| 126 | Notice, cancelling will not make 'get' unblock, besides if you build |
| 127 | 'isCancelled' calls into your function. |
| 128 | |
| 129 | Warning: the get function assumes that if you are the MainThread you |
| 130 | have the gdklock and if you are not the MainThread you don't have |
| 131 | the gdklock. |
| 132 | If this is not true, and the work is not done, calling get will |
| 133 | result in a deadlock. |
| 134 | If you haven't used the gtk.gdk.threads_enter nor |
| 135 | gtk.gdk.threads_leave function, everything should be fine.""" |
| 136 | |
| 137 | if not self.isDone(): |
| 138 | if type(currentThread()) == _MainThread: |
| 139 | threads_leave() |
| 140 | self.join(timeout) |
| 141 | if type(currentThread()) == _MainThread: |
| 142 | threads_enter() |
| 143 | if self.isAlive(): |
| 144 | return None |
| 145 | self.done = True |
| 146 | return self.result |
| 147 | |
| 148 | def execute (self): |
| 149 | """ Start the worker """ |
no test coverage detected