class EventClient(WebSocketClient):
def __init__(self, url, filters, on_event):
- # Prefer system's CA certificates (if available)
- ssl_options = {}
- certs_path = '/etc/ssl/certs/ca-certificates.crt'
- if os.path.exists(certs_path):
- ssl_options['ca_certs'] = certs_path
+ ssl_options = {'ca_certs': arvados.util.ca_certs_path()}
if config.flag_is_true('ARVADOS_API_HOST_INSECURE'):
ssl_options['cert_reqs'] = ssl.CERT_NONE
else:
self.filters = [[]]
self.on_event = on_event
self.poll_time = poll_time
+ self.daemon = True
self.stop = threading.Event()
def run(self):
client.close_connection()
def subscribe(api, filters, on_event, poll_fallback=15):
- '''
- api: a client object retrieved from arvados.api(). The caller should not use this client object for anything else after calling subscribe().
- filters: Initial subscription filters.
- on_event: The callback when a message is received.
- poll_fallback: If websockets are not available, fall back to polling every N seconds. If poll_fallback=False, this will return None if websockets are not available.
- '''
+ """
+ :api:
+ a client object retrieved from arvados.api(). The caller should not use this client object for anything else after calling subscribe().
+ :filters:
+ Initial subscription filters.
+ :on_event:
+ The callback when a message is received.
+ :poll_fallback:
+ If websockets are not available, fall back to polling every N seconds. If poll_fallback=False, this will return None if websockets are not available.
+ """
+
if not poll_fallback:
return _subscribe_websocket(api, filters, on_event)