Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Matevz Golob
erp5
Commits
a87f9a98
Commit
a87f9a98
authored
Jan 07, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
taskdistribution: really fix lock to avoid errors with concurrent RPC calls
parent
11f58766
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
erp5/util/taskdistribution/__init__.py
erp5/util/taskdistribution/__init__.py
+21
-15
No files found.
erp5/util/taskdistribution/__init__.py
View file @
a87f9a98
...
...
@@ -96,22 +96,14 @@ def patchRPCParser(error_handler):
parser_klass
.
feed
=
verbose_feed
class
RPCRetry
(
object
):
def
__init__
(
self
,
proxy
,
retry_time
,
logger
,
timeout
=
120
):
def
__init__
(
self
,
proxy
,
retry_time
,
logger
):
super
(
RPCRetry
,
self
).
__init__
()
self
.
_proxy
=
proxy
self
.
_retry_time
=
retry_time
self
.
_logger
=
logger
self
.
__rpc_lock
=
threading
.
Lock
()
self
.
timeout
=
timeout
def
_RPC
(
self
,
func_id
,
args
=
()):
default_timeout
=
socket
.
getdefaulttimeout
()
socket
.
setdefaulttimeout
(
self
.
timeout
)
try
:
with
self
.
__rpc_lock
:
return
getattr
(
self
.
_proxy
,
func_id
)(
*
args
)
finally
:
socket
.
setdefaulttimeout
(
default_timeout
)
def
_retryRPC
(
self
,
func_id
,
args
=
()):
retry_time
=
self
.
_retry_time
...
...
@@ -359,6 +351,23 @@ class TestResultProxy(RPCRetry):
cond
.
notify
()
self
.
_watcher_thread
.
join
()
class
ServerProxy
(
xmlrpclib
.
ServerProxy
):
def
__init__
(
self
,
*
args
,
**
kw
):
xmlrpclib
.
ServerProxy
.
__init__
(
self
,
*
args
,
**
kw
)
transport
=
self
.
__transport
def
make_connection
(
*
args
,
**
kw
):
conn
=
transport
.
__class__
.
make_connection
(
transport
,
*
args
,
**
kw
)
assert
hasattr
(
conn
,
'timeout'
),
conn
conn
.
timeout
=
120
return
conn
transport
.
make_connection
=
make_connection
self
.
__rpc_lock
=
threading
.
Lock
()
def
__request
(
self
,
*
args
,
**
kw
):
with
self
.
__rpc_lock
:
return
xmlrpclib
.
ServerProxy
.
__request
(
self
,
*
args
,
**
kw
)
class
TaskDistributionTool
(
RPCRetry
):
def
__init__
(
self
,
portal_url
,
retry_time
=
64
,
logger
=
None
):
"""
...
...
@@ -371,7 +380,7 @@ class TaskDistributionTool(RPCRetry):
if
portal_url
is
None
:
proxy
=
DummyTaskDistributionTool
()
else
:
proxy
=
xmlrpclib
.
ServerProxy
(
proxy
=
ServerProxy
(
portal_url
,
allow_none
=
True
,
).
portal_task_distribution
...
...
@@ -423,10 +432,7 @@ class TaskDistributor(RPCRetry):
if
portal_url
is
None
:
proxy
=
DummyTaskDistributionTool
()
else
:
proxy
=
xmlrpclib
.
ServerProxy
(
portal_url
,
allow_none
=
True
,
)
proxy
=
ServerProxy
(
portal_url
,
allow_none
=
True
)
super
(
TaskDistributor
,
self
).
__init__
(
proxy
,
retry_time
,
logger
)
protocol_revision
=
self
.
_retryRPC
(
'getProtocolRevision'
)
if
protocol_revision
!=
1
:
...
...
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