|
|
@@ -1,3 +1,5 @@
|
|
|
+from threading import Thread
|
|
|
+
|
|
|
from logger import Logger
|
|
|
|
|
|
|
|
|
@@ -24,14 +26,21 @@ class EventDriver(Logger):
|
|
|
if self.root_area.contains_event(event):
|
|
|
self.root_area.delegate_event(event)
|
|
|
|
|
|
- def start(self):
|
|
|
+ def start(self, threaded=False):
|
|
|
"""
|
|
|
Start the event loop. A root area is needed to be able to delegate
|
|
|
- events, so check if it exists first.
|
|
|
+ events, so check if it exists first. The argument determines if the
|
|
|
+ driver should start in a new (daemon) thread.
|
|
|
"""
|
|
|
if not self.root_area:
|
|
|
raise ValueError('Cannot start event server without root area.')
|
|
|
|
|
|
+ if threaded:
|
|
|
+ thread = Thread(target=self.start)
|
|
|
+ thread.daemon = True
|
|
|
+ thread.start()
|
|
|
+ return thread
|
|
|
+
|
|
|
self.start_loop()
|
|
|
|
|
|
def start_loop(self):
|