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
Gabrecht, Marco
lab-stream
Commits
87914ee3
Commit
87914ee3
authored
Mar 02, 2021
by
Nane Kratzke
Browse files
Add hostname to producer message
parent
819b8f41
Changes
1
Hide whitespace changes
Inline
Side-by-side
producer/pubsub.py
View file @
87914ee3
import
os
,
time
,
random
,
json
import
os
,
time
,
random
,
json
,
socket
import
redis
import
redis
host
=
os
.
environ
.
get
(
"REDIS_SVC"
,
"redis-svc"
)
host
=
os
.
environ
.
get
(
"REDIS_SVC"
,
"redis-svc"
)
...
@@ -7,9 +7,10 @@ channel = os.environ.get("CHANNEL", "xfan")
...
@@ -7,9 +7,10 @@ channel = os.environ.get("CHANNEL", "xfan")
stream
=
redis
.
Redis
(
host
=
host
,
port
=
port
,
db
=
0
)
stream
=
redis
.
Redis
(
host
=
host
,
port
=
port
,
db
=
0
)
me
=
socket
.
gethostname
()
i
=
1
i
=
1
while
True
:
while
True
:
msg
=
f
"
M
essage
{
i
}
"
msg
=
f
"
Hi, this is the m
essage
#
{
i
}
from
{
me
}
.
"
i
=
i
+
1
i
=
i
+
1
n
=
random
.
randint
(
1
,
3
)
n
=
random
.
randint
(
1
,
3
)
time
.
sleep
(
n
)
time
.
sleep
(
n
)
...
...
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