Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
1777b8f4
Commit
1777b8f4
authored
Mar 23, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ansible: use DeduplicatingService for ContextService; closes #162.
parent
f6b5d9f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
17 deletions
+8
-17
ansible_mitogen/services.py
ansible_mitogen/services.py
+8
-17
No files found.
ansible_mitogen/services.py
View file @
1777b8f4
...
...
@@ -30,7 +30,7 @@ from __future__ import absolute_import
import
mitogen.service
class
ContextService
(
mitogen
.
service
.
Service
):
class
ContextService
(
mitogen
.
service
.
Deduplicating
Service
):
"""
Used by worker processes connecting back into the top-level process to
fetch the single Context instance corresponding to the supplied connection
...
...
@@ -60,20 +60,11 @@ class ContextService(mitogen.service.Service):
"""
handle
=
500
max_message_size
=
1000
required_args
=
{
'method'
:
str
}
def
__init__
(
self
,
router
):
super
(
ContextService
,
self
).
__init__
(
router
)
self
.
_context_by_key
=
{}
def
validate_args
(
self
,
args
):
return
isinstance
(
args
,
dict
)
def
dispatch
(
self
,
dct
,
msg
):
key
=
repr
(
sorted
(
dct
.
items
()))
dct
.
pop
(
'discriminator'
,
None
)
if
key
not
in
self
.
_context_by_key
:
method
=
getattr
(
self
.
router
,
dct
.
pop
(
'method'
))
self
.
_context_by_key
[
key
]
=
method
(
**
dct
)
return
self
.
_context_by_key
[
key
]
def
get_response
(
self
,
args
):
args
.
pop
(
'discriminator'
,
None
)
method
=
getattr
(
self
.
router
,
args
.
pop
(
'method'
))
return
method
(
**
args
)
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