mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-23 00:21:32 +00:00
Add method EventHandlerBase.cleanup()
This commit is contained in:
parent
fd029dbfe7
commit
1d47ca5684
@ -58,7 +58,7 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.monitor = DirectoryMonitor(directory)
|
self.monitor = DirectoryMonitor(directory)
|
||||||
self.monitor.watch() # This runs on a separate thread TODO: when to call stop()?
|
self.monitor.watch() # This runs on a separate thread
|
||||||
|
|
||||||
def read(self, data):
|
def read(self, data):
|
||||||
try: data['content'] = self.filemanager.file_contents
|
try: data['content'] = self.filemanager.file_contents
|
||||||
@ -89,6 +89,9 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
|||||||
self.attach_fileinfo(data)
|
self.attach_fileinfo(data)
|
||||||
return data_json
|
return data_json
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
self.monitor.stop()
|
||||||
|
|
||||||
|
|
||||||
def map_file_extension_to_language(filename):
|
def map_file_extension_to_language(filename):
|
||||||
language_map = {
|
language_map = {
|
||||||
|
@ -23,6 +23,9 @@ class EventHandlerBase:
|
|||||||
def handle_reset(self, data_json):
|
def handle_reset(self, data_json):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def message_other(self, anchor, data):
|
def message_other(self, anchor, data):
|
||||||
message = {
|
message = {
|
||||||
'anchor': anchor,
|
'anchor': anchor,
|
||||||
|
@ -6,6 +6,9 @@ from tfw.config import tfwenv
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
anchor_webide = SourceCodeEventHandler('anchor_webide', tfwenv.WEBIDE_WD, 'login')
|
eventhandlers = {SourceCodeEventHandler('anchor_webide', tfwenv.WEBIDE_WD, 'login'),
|
||||||
anchor_terminado = TerminadoEventHandler('anchor_terminado', 'terminado')
|
TerminadoEventHandler('anchor_terminado', 'terminado')}
|
||||||
|
try:
|
||||||
IOLoop.instance().start()
|
IOLoop.instance().start()
|
||||||
|
finally:
|
||||||
|
for eh in eventhandlers: eh.cleanup()
|
||||||
|
Loading…
Reference in New Issue
Block a user