Owner thread class for gate demo
| 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): |