Skip to content

Instantly share code, notes, and snippets.

@BrandonClapp
Created May 12, 2020 22:37
Show Gist options
  • Save BrandonClapp/edb81aa071888e290d50f81ebad0a44b to your computer and use it in GitHub Desktop.
Save BrandonClapp/edb81aa071888e290d50f81ebad0a44b to your computer and use it in GitHub Desktop.
# Dictionary to store stream responses in
responses = {
"123": [],
"456": [],
}
# Dummy stream
port_123_stream = ["I am a line", "I like cake", "Turtles too"]
port_456_stream = ["Some other line", "Pizza party", "Puppy power"]
# Dummy subscription to the port's stream
for line in port_123_stream:
port = "123"
responses[port].append(line)
# Dummy subscription to another port's stream.
for line in port_456_stream:
port = "456"
responses[port].append(line)
# Should output something like
# {'123': ['I am a line', 'I like cake', 'Turtles too'], '456': ['Some other line', 'Pizza party', 'Puppy power']}
print(responses)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment