Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
8fccdaf6
Unverified
Commit
8fccdaf6
authored
Jun 17, 2020
by
Chao Ma
Committed by
GitHub
Jun 17, 2020
Browse files
[RPC] HandleCtrlC Register for handling Ctrl+C event. (#1652)
* update * update * update * update * fix lint
parent
b372b3c7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
python/dgl/distributed/rpc.py
python/dgl/distributed/rpc.py
+5
-0
python/dgl/distributed/rpc_server.py
python/dgl/distributed/rpc_server.py
+2
-0
src/rpc/rpc.cc
src/rpc/rpc.cc
+26
-0
No files found.
python/dgl/distributed/rpc.py
View file @
8fccdaf6
...
...
@@ -893,6 +893,11 @@ def fast_pull(name, id_tensor, part_id, service_id,
F
.
zerocopy_to_dgl_ndarray
(
local_data
))
return
F
.
zerocopy_from_dgl_ndarray
(
res_tensor
)
def
register_ctrl_c
():
"""HandleCtrlC Register for handling Ctrl+C event.
"""
_CAPI_DGLRPCHandleCtrlC
()
############### Some basic services will be defined here #############
CLIENT_REGISTER
=
22451
...
...
python/dgl/distributed/rpc_server.py
View file @
8fccdaf6
...
...
@@ -35,6 +35,8 @@ def start_server(server_id, ip_config, num_clients, server_state, \
assert
num_clients
>=
0
,
'num_client (%d) cannot be a negative number.'
%
num_client
assert
max_queue_size
>
0
,
'queue_size (%d) cannot be a negative number.'
%
queue_size
assert
net_type
in
(
'socket'
),
'net_type (%s) can only be
\'
socket
\'
'
%
net_type
# HandleCtrlC Register for handling Ctrl+C event
rpc
.
register_ctrl_c
()
# Register some basic services
rpc
.
register_service
(
rpc
.
CLIENT_REGISTER
,
rpc
.
ClientRegisterRequest
,
...
...
src/rpc/rpc.cc
View file @
8fccdaf6
...
...
@@ -5,6 +5,11 @@
*/
#include "./rpc.h"
#include <csignal>
#if defined(__linux__)
#include <unistd.h>
#endif
#include <dgl/runtime/container.h>
#include <dgl/packed_func_ext.h>
#include <dgl/array.h>
...
...
@@ -289,6 +294,27 @@ DGL_REGISTER_GLOBAL("distributed.rpc._CAPI_DGLRPCMessageGetTensors")
*
rv
=
ret
;
});
#if defined(__linux__)
/*!
* \brief CtrlCHandler, exits if Ctrl+C is pressed
* \param s signal
*/
void
CtrlCHandler
(
int
s
)
{
LOG
(
INFO
)
<<
"
\n
User pressed Ctrl+C, Exiting"
;
exit
(
1
);
}
DGL_REGISTER_GLOBAL
(
"distributed.rpc._CAPI_DGLRPCHandleCtrlC"
)
.
set_body
([]
(
DGLArgs
args
,
DGLRetValue
*
rv
)
{
// Ctrl+C handler
struct
sigaction
sigIntHandler
;
sigIntHandler
.
sa_handler
=
CtrlCHandler
;
sigemptyset
(
&
sigIntHandler
.
sa_mask
);
sigIntHandler
.
sa_flags
=
0
;
sigaction
(
SIGINT
,
&
sigIntHandler
,
nullptr
);
});
#endif
//////////////////////////// ServerState ////////////////////////////
DGL_REGISTER_GLOBAL
(
"distributed.server_state._CAPI_DGLRPCGetServerState"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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