Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sjrpc
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
sjrpc
Commits
e7697c16
Commit
e7697c16
authored
14 years ago
by
Antoine Millet
Browse files
Options
Downloads
Patches
Plain Diff
[bug#3961] New argument appeared to set a global call timeout.
parent
4c01cecf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sjrpc/client/simple.py
+5
-2
5 additions, 2 deletions
sjrpc/client/simple.py
sjrpc/core/rpcconnection.py
+11
-6
11 additions, 6 deletions
sjrpc/core/rpcconnection.py
with
16 additions
and
8 deletions
sjrpc/client/simple.py
+
5
−
2
View file @
e7697c16
...
...
@@ -25,8 +25,8 @@ class SimpleRpcClient(ConnectionManager):
self
.
register
(
self
.
_connection
)
@classmethod
def
from_addr
(
cls
,
addr
,
port
,
enable_ssl
=
False
,
cert
=
None
,
timeout
=
30.0
,
default_handler
=
None
,
on_disconnect
=
None
):
def
from_addr
(
cls
,
addr
,
port
,
enable_ssl
=
False
,
cert
=
None
,
timeout
=
None
,
conn_timeout
=
30.0
,
default_handler
=
None
,
on_disconnect
=
None
):
'''
Construct the instance of :class:`SimpleRpcClient` without providing
the :class:`RpcConnection` object. The :class:`RpcConnection` is
...
...
@@ -36,6 +36,8 @@ class SimpleRpcClient(ConnectionManager):
:param addr: the target ip address
:param port: the target port
:param ssl: enable SSL
:param timeout: the global call timeout setting
:param conn_timeout: the connection operation timeout
:param cert: is SSL is enabled, profile the filename of certificate to
check. If None, don
'
t check certificate.
:param default_handler: the default handler to bind to the
...
...
@@ -45,6 +47,7 @@ class SimpleRpcClient(ConnectionManager):
'''
connection
=
RpcConnection
.
from_addr
(
addr
,
port
,
None
,
timeout
=
timeout
,
conn_timeout
=
conn_timeout
,
enable_ssl
=
enable_ssl
,
cert
=
cert
)
client
=
cls
(
connection
,
default_handler
=
default_handler
,
on_disconnect
=
on_disconnect
)
...
...
This diff is collapsed.
Click to expand it.
sjrpc/core/rpcconnection.py
+
11
−
6
View file @
e7697c16
...
...
@@ -29,7 +29,7 @@ class RpcConnection(object):
REQUEST_MESSAGE
=
{
'
id
'
:
None
,
'
method
'
:
None
,
'
args
'
:
[],
'
kwargs
'
:
{}}
RESPONSE_MESSAGE
=
{
'
id
'
:
None
,
'
return
'
:
None
,
'
error
'
:
None
}
def
__init__
(
self
,
sock
,
manager
,
handler
=
None
):
def
__init__
(
self
,
sock
,
manager
,
handler
=
None
,
timeout
=
None
):
# Sock of this connection:
self
.
_sock
=
sock
...
...
@@ -58,9 +58,12 @@ class RpcConnection(object):
# Is the RpcConnection connected to its peer:
self
.
_connected
=
True
# The global call timeout setting:
self
.
_call_timeout
=
timeout
@classmethod
def
from_addr
(
cls
,
addr
,
port
,
manager
,
enable_ssl
=
False
,
timeout
=
30.0
,
cert
=
None
,
handler
=
None
):
def
from_addr
(
cls
,
addr
,
port
,
manager
,
enable_ssl
=
False
,
timeout
=
None
,
conn_timeout
=
30.0
,
cert
=
None
,
handler
=
None
):
'''
Construct the instance of :class:`RpcConnection` without providing
the :class:`socket` object. Socket is automatically created and passed
...
...
@@ -70,6 +73,8 @@ class RpcConnection(object):
:param port: the target port
:param manager: manager of this connection
:param enable_ssl: enable SSL
:param timeout: the global call timeout setting
:param conn_timeout: the connection operation timeout
:param cert: is SSL is enabled, profile the filename of certificate to
check. If None, don
'
t check certificate.
:param handler: Handler to attach to this :class:`RpcConnection` object
...
...
@@ -81,10 +86,10 @@ class RpcConnection(object):
req
=
ssl
.
CERT_NONE
if
cert
is
None
else
ssl
.
CERT_REQUIRED
sock
=
ssl
.
wrap_socket
(
sock
,
certfile
=
None
,
cert_reqs
=
req
,
ssl_version
=
ssl
.
PROTOCOL_TLSv1
)
sock
.
settimeout
(
timeout
)
sock
.
settimeout
(
conn_
timeout
)
sock
.
connect
((
addr
,
port
))
sock
.
setblocking
(
False
)
return
cls
(
sock
,
manager
,
handler
)
return
cls
(
sock
,
manager
,
handler
,
timeout
=
timeout
)
def
__repr__
(
self
):
return
'
<RpcConnection object>
'
...
...
@@ -261,7 +266,7 @@ class RpcConnection(object):
timeout
=
kwargs
[
'
_timeout
'
]
del
kwargs
[
'
_timeout
'
]
else
:
timeout
=
None
timeout
=
self
.
_call_timeout
# Send the call to the peer:
msg_id
=
self
.
_send_call
(
method_name
,
*
args
,
**
kwargs
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment