Advertisement
the-technoholik

GarageDoorMonitor

Nov 8th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. class GarageDoorMonitor(NonBlockingMonitor, Garage):
  2.     _doOpen = None
  3.     _doClose = None
  4.  
  5.     def __init__(self, openMethod, closeMethod):
  6.         """Create a new monitor to manage concurrent access to the door.
  7.  
  8.        Params:
  9.            openMethod      the method to call to actually open the door.
  10.                            You may need to time.sleep() there.
  11.            closeMethod     the method to call to actually close the door.
  12.                            You may need to time.sleep() there.
  13.        """
  14.         NonBlockingMonitor.__init__(self)
  15.         Garage.__init__(self)
  16.         self._doOpen = openMethod
  17.         self._doClose = closeMethod
  18.  
  19.     def open(self):
  20.         return self.do(self._doOpen)
  21.  
  22.     def close(self):
  23.         return self.do(self._doClose)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement