I have a Redis client in the cache file:
from redis import Redis
client = Redis(host='0.0.0.0', port=6379, db=0)
That I use to subscribe in the task file:
from cache import client
pubsub = client.pubsub()
def show(message):
print(message.get('data'))
pubsub.subscribe(**{'msg': show})
Then in a Flask route in the server file I publish a message in the channel msg:
from cache import client
client.publish(
'msg',
'( :'
)
But when I make a request to the route, nothing is published, or it is but nothing is shown. I have already try to see the log, read the documentation, use the execute command, looked a similar example, etc, but nothing worked. Here's the code to a more detailed context. Any tips?
Obs: As you can see in the code on the Github repository, the subscribe and the publish are in different threads