1
0
зеркало из https://github.com/avatao-content/baseimage-tutorial-framework synced 2026-01-08 16:21:49 +00:00

Add method EventHandlerBase.cleanup()

Этот коммит содержится в:
Kristóf Tóth
2018-02-13 15:38:46 +01:00
родитель fd029dbfe7
Коммит 1d47ca5684
3 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@@ -58,7 +58,7 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
}
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):
try: data['content'] = self.filemanager.file_contents
@@ -89,6 +89,9 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
self.attach_fileinfo(data)
return data_json
def cleanup(self):
self.monitor.stop()
def map_file_extension_to_language(filename):
language_map = {

Просмотреть файл

@@ -23,6 +23,9 @@ class EventHandlerBase:
def handle_reset(self, data_json):
return None
def cleanup(self):
pass
def message_other(self, anchor, data):
message = {
'anchor': anchor,

Просмотреть файл

@@ -6,6 +6,9 @@ from tfw.config import tfwenv
if __name__ == '__main__':
anchor_webide = SourceCodeEventHandler('anchor_webide', tfwenv.WEBIDE_WD, 'login')
anchor_terminado = TerminadoEventHandler('anchor_terminado', 'terminado')
IOLoop.instance().start()
eventhandlers = {SourceCodeEventHandler('anchor_webide', tfwenv.WEBIDE_WD, 'login'),
TerminadoEventHandler('anchor_terminado', 'terminado')}
try:
IOLoop.instance().start()
finally:
for eh in eventhandlers: eh.cleanup()