MCPcopy Create free account
hub / github.com/ActiveState/code / get

Method get

recipes/Python/521881_GtkWorker/recipe-521881.py:121–146  ·  view source on GitHub ↗

'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)

Source from the content-addressed store, hash-verified

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 """

Callers 12

runMethod · 0.45
nextMethod · 0.45
_getFromCacheMethod · 0.45
__setitem__Method · 0.45
gotHeadersMethod · 0.45
getRequestHeadersFunction · 0.45
runMethod · 0.45
callbackFunction · 0.45
incrMethod · 0.45
decrMethod · 0.45
valMethod · 0.45
__new__Method · 0.45

Calls 2

isDoneMethod · 0.95
joinMethod · 0.45

Tested by

no test coverage detected