Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 1 | import threading |
| 2 | import time |
Scott Baker | 0355284 | 2015-02-18 16:13:48 -0800 | [diff] [blame] | 3 | from ec2_observer.event_loop import XOSObserver |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 4 | from ec2_observer.event_manager import EventListener |
| 5 | from util.logger import Logger, logging |
| 6 | |
| 7 | logger = Logger(level=logging.INFO) |
| 8 | |
| 9 | class Backend: |
| 10 | |
| 11 | def run(self): |
Sapan Bhatia | ed83cf6 | 2014-07-22 00:35:56 -0400 | [diff] [blame] | 12 | # start the openstack observer |
Scott Baker | 0355284 | 2015-02-18 16:13:48 -0800 | [diff] [blame] | 13 | observer = XOSObserver() |
Sapan Bhatia | ed83cf6 | 2014-07-22 00:35:56 -0400 | [diff] [blame] | 14 | observer_thread = threading.Thread(target=observer.run) |
| 15 | observer_thread.start() |
| 16 | |
| 17 | # start event listene |
| 18 | event_manager = EventListener(wake_up=observer.wake_up) |
| 19 | event_manager_thread = threading.Thread(target=event_manager.run) |
| 20 | event_manager_thread.start() |
| 21 | logger.log_exc("Exception in child thread") |
Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame] | 22 | |