Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
7750d6d6
Commit
7750d6d6
authored
May 08, 2021
by
Cyril Guilloud
Browse files
Better identification of com. errors in RPC and XIA
parent
37210d7c
Pipeline
#46495
passed with stages
in 108 minutes and 8 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bliss/comm/rpc.py
View file @
7750d6d6
...
...
@@ -91,6 +91,7 @@ from bliss import global_map
from
bliss.common.msgpack_ext
import
MsgpackContext
from
bliss.comm.exceptions
import
CommunicationError
from
bliss.common.greenlet_utils
import
Timeout
as
GreenletTimeoutError
MAX_MEMORY
=
min
(
psutil
.
virtual_memory
().
total
,
sys
.
maxsize
)
...
...
@@ -541,9 +542,19 @@ class RpcConnection:
# Disable Nagle and set TOS to low delay
self
.
_socket
.
setsockopt
(
socket
.
IPPROTO_TCP
,
socket
.
TCP_NODELAY
,
1
)
self
.
_socket
.
setsockopt
(
socket
.
SOL_IP
,
socket
.
IP_TOS
,
0x10
)
except
socket
.
gaierror
as
sockexc
:
_msg
=
f
"RPC socket.gaierror connecting to
{
self
.
host
}
:
{
self
.
port
}
- ERR no
{
sockexc
.
errno
}
:
{
sockexc
.
strerror
}
"
raise
CommunicationError
(
_msg
)
from
sockexc
except
socket
.
gaierror
as
sock_err
:
_msg
=
f
"socket.gaierror connecting to
{
self
.
host
}
:
{
self
.
port
}
- ERR no
{
sock_err
.
errno
}
:
{
sock_err
.
strerror
}
"
raise
CommunicationError
(
_msg
)
from
sock_err
except
socket
.
timeout
as
sock_err
:
_msg
=
f
"socket.timeout error connecting to
{
self
.
host
}
:
{
self
.
port
}
"
raise
CommunicationError
(
_msg
)
from
sock_err
except
GreenletTimeoutError
as
grt_err
:
_msg
=
f
"RPC GreenletTimeoutError connecting to
{
self
.
host
}
:
{
self
.
port
}
"
raise
CommunicationError
(
_msg
)
from
grt_err
except
ConnectionRefusedError
as
cnx_err
:
_msg
=
f
"RPC ConnectionRefusedError error connecting to
{
self
.
host
}
:
{
self
.
port
}
"
raise
CommunicationError
(
_msg
)
from
cnx_err
...
...
@@ -552,6 +563,7 @@ class RpcConnection:
# ??? no host
self
.
_socket
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
self
.
_socket
.
connect
(
self
.
port
)
self
.
_reading_task
=
gevent
.
spawn
(
self
.
_raw_read
)
def
get_class
(
self
):
...
...
@@ -639,6 +651,7 @@ class RpcConnection:
def
_raw_read
(
self
):
unpacker
=
msgpack
.
Unpacker
(
raw
=
False
,
max_buffer_size
=
MAX_BUFFER_SIZE
)
exception
=
None
try
:
while
True
:
msg
=
self
.
_socket
.
recv
(
READ_BUFFER_SIZE
)
...
...
@@ -658,8 +671,8 @@ class RpcConnection:
wq
=
self
.
_queues
.
get
(
call_id
)
if
wq
:
wq
.
put
(
return_values
)
except
Exception
as
e
:
exception
=
e
except
Exception
as
e
rr
:
exception
=
e
rr
sys
.
excepthook
(
*
sys
.
exc_info
())
finally
:
for
_
,
wq
in
self
.
_queues
.
items
():
...
...
bliss/controllers/mca/xia.py
View file @
7750d6d6
...
...
@@ -9,10 +9,14 @@
# Imports
import
enum
import
socket
from
bliss
import
is_bliss_shell
from
bliss.common.logtools
import
log_debug
,
user_print
from
bliss.common
import
event
from
bliss.config.beacon_object
import
BeaconObject
from
bliss.comm.exceptions
import
CommunicationError
from
bliss.common.greenlet_utils
import
Timeout
as
GreenletTimeoutError
from
bliss.comm
import
rpc
from
.base
import
(
...
...
@@ -116,16 +120,37 @@ class BaseXIA(BaseMCA):
self
.
gate_polarity
=
self
.
config
.
get
(
"gate_polarity"
,
GatePolarity
.
NORMAL
)
def
initialize_hardware
(
self
):
""" Called at session startup
"""
Called at session startup
"""
logger
.
debug
(
"initialize_hardware()"
)
self
.
_proxy
=
rpc
.
Client
(
self
.
beacon_obj
.
url
)
event
.
connect
(
self
.
_proxy
,
"data"
,
self
.
_event
)
event
.
connect
(
self
.
_proxy
,
"current_pixel"
,
self
.
_current_pixel_event
)
try
:
self
.
_proxy
=
rpc
.
Client
(
self
.
beacon_obj
.
url
)
event
.
connect
(
self
.
_proxy
,
"data"
,
self
.
_event
)
event
.
connect
(
self
.
_proxy
,
"current_pixel"
,
self
.
_current_pixel_event
)
except
CommunicationError
as
prox_comm_err
:
_msg
=
f
"XIA init error: cannot connect to
{
self
.
url
}
"
# breakpoint()
if
isinstance
(
prox_comm_err
.
__cause__
,
GreenletTimeoutError
):
_msg
+=
" GreenletTimeoutError (check server is running ?)"
elif
isinstance
(
prox_comm_err
.
__cause__
,
socket
.
gaierror
):
_msg
+=
" socket.gaierror (check host ?)"
elif
isinstance
(
prox_comm_err
.
__cause__
,
ConnectionRefusedError
):
_msg
+=
" ConnectionRefusedError (check host/port/FW ?)"
else
:
_msg
+=
" CommError (check ?)"
raise
CommunicationError
(
_msg
)
from
prox_comm_err
except
BaseException
as
base_err
:
# got a greenlet timeout...
_msg
=
f
"XIA init error: cannot connect to
{
self
.
url
}
"
_msg
+=
f
" greenlet timeout (check server is running?)"
raise
CommunicationError
(
_msg
)
from
base_err
# global_map.register(self._proxy, parents_list=[self], tag="comm")
try
:
# Getting the current configuration will
# Call load_configuration on the first peers.
# Accessing to current configuration will
# call load_configuration on the first peers.
# pylint: disable=pointless-statement
self
.
beacon_obj
.
current_configuration
logger
.
debug
(
"current_configuration=%s"
,
self
.
beacon_obj
.
current_configuration
...
...
doc/docs/beacon_channels.md
View file @
7750d6d6
...
...
@@ -110,3 +110,9 @@ BLISS [5]: ['event 0', 'event 1', 'event 2', 'event 3', 'event 4',
'event 5'
,
'event 6'
,
'event 7'
,
'event 8'
,
'event 9'
]
```
To disconnect the channel in process B:
```
python
c
.
unregister_callback
(
f
)
```
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment