From 3d9954613a9633eddd7fa7152ee69fdff2b7344a Mon Sep 17 00:00:00 2001 From: ShenYuhan Date: Wed, 26 Aug 2020 19:35:24 +0800 Subject: [PATCH] add timeout for file queue (#772) --- visualdl/writer/record_writer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/visualdl/writer/record_writer.py b/visualdl/writer/record_writer.py index e80e0ff9..01ea1ad4 100644 --- a/visualdl/writer/record_writer.py +++ b/visualdl/writer/record_writer.py @@ -21,6 +21,9 @@ import struct import time import queue import threading +import os + +QUEUE_TIMEOUT = os.getenv("VDL_QUEUE_TIMEOUT") class RecordWriter(object): @@ -145,7 +148,10 @@ class _AsyncWriter(object): with self._lock: if self._closed: raise IOError("Writer is closed.") - self._bytes_queue.put(bytestring) + try: + self._bytes_queue.put(bytestring, timeout=QUEUE_TIMEOUT) + except queue.Full: + print('This data was not written to the log due to timeout.') def flush(self): with self._lock: -- GitLab