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

Class OwnerThread

recipes/Python/576418_Multithreaded_FIFO_Gate/recipe-576418.py:154–176  ·  view source on GitHub ↗

Owner thread class for gate demo

Source from the content-addressed store, hash-verified

152
153
154 class OwnerThread(threading.Thread):
155 """ Owner thread class for gate demo """
156
157 def __init__(self, gate):
158 self.gate = gate
159 threading.Thread.__init__(self, None, 'Owner thread')
160
161 def run(self):
162 # Close the gate
163 print 'Closing gate...'
164 ret = self.gate.close()
165 if ret==0:
166 print 'Gate closed successfully'
167
168 print 'Gate count=>',self.gate.get_count()
169
170 # Open gate after sleeping some time
171 time.sleep(5)
172 if ret==0:
173 print 'Opening gate'
174 self.gate.open()
175 else:
176 print 'Gate closing not successful'
177
178
179 class SampleThread(threading.Thread):

Callers 2

test1Function · 0.85
test2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected