Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
NERON
TPmqRabbit
Commits
5c64f8ce
Commit
5c64f8ce
authored
Nov 24, 2017
by
Browse files
un peu de lisibilité en plus
parent
0ea78a83
Changes
1
Hide whitespace changes
Inline
Side-by-side
lamportclient.py
View file @
5c64f8ce
...
...
@@ -66,7 +66,8 @@ class LamportClient:
self
.
initializeCycle
,
self
.
init_reception
)
self
.
channel
.
basic_publish
(
exchange
=
"lamport_init"
,
body
=
"{} says : Hello World!"
.
format
(
self
.
id
),
routing_key
=
''
)
exchange
=
"lamport_init"
,
body
=
"{} says : Hello World!"
.
format
(
self
.
id
),
routing_key
=
''
)
print
(
"saying hello to the world"
)
self
.
channel
.
start_consuming
()
...
...
@@ -91,11 +92,12 @@ class LamportClient:
#client.free()
def
initializeCycle
(
self
,
channel
,
method
,
properties
,
body
):
#
_,body,_ = str(body).split("'")
_
,
body
,
_
=
str
(
body
).
split
(
"'"
)
arrival_id
=
int
(
body
.
split
(
" "
)[
0
])
self
.
n_clients_here
+=
1
print
(
"{} arrived!
\n
We are now {} of {}"
.
format
(
arrival_id
,
self
.
n_clients_here
,
self
.
n_clients_total
))
print
(
"{} arrived!
\n
We are now {} of {}"
.
format
(
arrival_id
,
self
.
n_clients_here
,
self
.
n_clients_total
))
if
self
.
n_clients_here
==
self
.
n_clients_total
:
self
.
channel
.
stop_consuming
()
...
...
@@ -105,7 +107,8 @@ class LamportClient:
"""publish
send message to server
"""
self
.
channel
.
basic_publish
(
exchange
=
"lamport"
,
body
=
message
,
routing_key
=
''
)
self
.
channel
.
basic_publish
(
exchange
=
"lamport"
,
body
=
message
,
routing_key
=
''
)
def
request
(
self
):
"""request
...
...
@@ -152,7 +155,7 @@ class LamportClient:
def
when_receive
(
self
,
channel
,
method
,
properties
,
body
):
body
=
str
(
body
)
#
_,body,_ = body.split("'")
_
,
body
,
_
=
body
.
split
(
"'"
)
print
(
"received {}"
.
format
(
body
))
...
...
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