Improved KeyboardInterrupt Exception Handling (#5237)

This commit is contained in:
Richard Liaw
2019-07-22 02:29:56 -07:00
committed by GitHub
parent f9043cc49a
commit 53fb876a5f
5 changed files with 34 additions and 3 deletions
+7
View File
@@ -2,6 +2,7 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import redis
import threading
import traceback
@@ -11,6 +12,10 @@ from ray import cloudpickle as pickle
from ray import profiling
from ray import utils
import logging
logger = logging.getLogger(__name__)
class ImportThread(object):
"""A thread used to import exports from the driver or other workers.
@@ -80,6 +85,8 @@ class ImportThread(object):
num_imported += 1
key = self.redis_client.lindex("Exports", i)
self._process_key(key)
except (OSError, redis.exceptions.ConnectionError) as e:
logger.error("ImportThread: {}".format(e))
finally:
# Close the pubsub client to avoid leaking file descriptors.
import_pubsub_client.close()