mirror of https://github.com/m-labs/artiq.git
pc_rpc/BestEffortClient: add logging
This commit is contained in:
parent
a7405dea1c
commit
6d11da3887
|
@ -17,11 +17,15 @@ import asyncio
|
||||||
import traceback
|
import traceback
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
from artiq.protocols import pyon
|
from artiq.protocols import pyon
|
||||||
from artiq.protocols.asyncio_server import AsyncioServer as _AsyncioServer
|
from artiq.protocols.asyncio_server import AsyncioServer as _AsyncioServer
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class RemoteError(Exception):
|
class RemoteError(Exception):
|
||||||
"""Raised when a RPC failed or raised an exception on the remote (server)
|
"""Raised when a RPC failed or raised an exception on the remote (server)
|
||||||
side.
|
side.
|
||||||
|
@ -250,6 +254,9 @@ class BestEffortClient:
|
||||||
try:
|
try:
|
||||||
self.__coninit(firstcon_timeout)
|
self.__coninit(firstcon_timeout)
|
||||||
except:
|
except:
|
||||||
|
logger.warning("first connection attempt to %s:%d[%s] failed, "
|
||||||
|
"retrying in the background",
|
||||||
|
self.__host, self.__port, self.__target_name)
|
||||||
self.__start_conretry()
|
self.__start_conretry()
|
||||||
else:
|
else:
|
||||||
self.__conretry_thread = None
|
self.__conretry_thread = None
|
||||||
|
@ -281,6 +288,10 @@ class BestEffortClient:
|
||||||
time.sleep(self.__retry)
|
time.sleep(self.__retry)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
if not self.__conretry_terminate:
|
||||||
|
logger.warning("connection to %s:%d[%s] established in "
|
||||||
|
"the background",
|
||||||
|
self.__host, self.__port, self.__target_name)
|
||||||
if self.__conretry_terminate and self.__socket is not None:
|
if self.__conretry_terminate and self.__socket is not None:
|
||||||
self.__socket.close()
|
self.__socket.close()
|
||||||
# must be after __socket.close() to avoid race condition
|
# must be after __socket.close() to avoid race condition
|
||||||
|
@ -317,6 +328,10 @@ class BestEffortClient:
|
||||||
self.__send(obj)
|
self.__send(obj)
|
||||||
obj = self.__recv()
|
obj = self.__recv()
|
||||||
except:
|
except:
|
||||||
|
logger.warning("connection failed while attempting "
|
||||||
|
"RPC to %s:%d[%s], re-establishing connection "
|
||||||
|
"in the background",
|
||||||
|
self.__host, self.__port, self.__target_name)
|
||||||
self.__start_conretry()
|
self.__start_conretry()
|
||||||
else:
|
else:
|
||||||
if obj["status"] == "ok":
|
if obj["status"] == "ok":
|
||||||
|
|
Loading…
Reference in New Issue