Check if join was successful when waiting for std flush pool

This commit is contained in:
allegroai 2020-04-09 12:51:34 +03:00
parent 2f395cc76b
commit f61cbdeb39

View File

@ -150,8 +150,9 @@ class TaskHandler(BufferingHandler):
if self._pending <= 0: if self._pending <= 0:
break break
self.__log_stderr('INFO: trains.Task - flushing console logs (timeout {}s)'.format( self.__log_stderr('INFO: trains.Task - flushing console logs (timeout {}s)'.format(
self.__wait_for_flush_timeout-i)) float(self.__wait_for_flush_timeout-i)))
threadpool_waited_join(t, timeout=1.0) if threadpool_waited_join(t, timeout=1.0):
break
ll(msg % 7) ll(msg % 7)
except Exception: except Exception:
ll(msg % 8) ll(msg % 8)
@ -164,9 +165,8 @@ class TaskHandler(BufferingHandler):
ll(msg % 11) ll(msg % 11)
def close(self, wait=False): def close(self, wait=False):
self.__log_stderr('Closing {} {}'.format(self._task_id, wait)) import os
# import traceback self.__log_stderr('Closing {} wait={}'.format(os.getpid(), wait))
# self.__log_stderr('trace: {}'.format(traceback.format_stack()))
# super already calls self.flush() # super already calls self.flush()
super(TaskHandler, self).close() super(TaskHandler, self).close()
# shut down the TaskHandler, from this point onwards. No events will be logged # shut down the TaskHandler, from this point onwards. No events will be logged