Neural Network is set of algorithm which follows the working of human brain. It has dense cells called neurons which are helpful for system to learn things. For neural network we need at least 3 layers, Input layer, hidden layer and output layer. …
EMQ X (Erlang/Enterprise/Elastic MQTT Broker) is open source IoT MQTT message broker. It is based on Erlang/OTP. MQTT is a lightweight message exchange protocol using publish-subscribe pattern. EMQX support TCP / SSL connection support.
What is RabbitMQ??
RabbitMQ is a message broker or queue manager or we…
This is blog for those people who wants to automate everything and loves python. The purpose of this blog to automate download Google drive text file from python code using gdown module. In one of my project I had requirement to download log.txt file from Google Drive and then show…
We can get notification when the key expires in redis. This feature can be implemented by Redis Keyspace notification. For this we have to set configuration (notify-keyspace-events “KEx”) in the redis.conf file.
K for keyspace events, E for keyevent events and x for expire. This configuration informs us when any key is expired.
Set configuration from redis-cli — config set notify-keyspace-events KEx
Set configuration from redis.conf file — notify-keyspace-events “KEx”
Python Code to get notification of expired keys-
#importing redis import redis#connecting redis redis_connection = redis.StrictRedis(host='localhost', port=6379, db=0)#publish of redis events redis_subscriber = redis_connection.pubsub()""" subscribe event for all keys. * means all the keys, if we want any specific key we have to give #that key name. """ redis_subscriber.psubscribe('__keyspace@0__:*')#listening message or notification of redis event. for msg in redis_subscriber.listen(): print(msg)
We all are using python logging module but sometimes it complicated to identify the particular log. So, I am going to explain another python module which is quite interesting to use in your code. That module name is “logzero”
logging vs logzero
Logging is used by every python developer. The sample uses of logging module is given below.
import logging logging.warning(‘Warning message from your code.’) logging.error(‘Error message from your code.’) logging.critical(‘Critical message from your code.’)
The working of logging and logzero is same but logzero is Pretty formatting, including level-specific colors in the console. For logzero first you have to install logzero module viapip3 install logzero. The sample uses of logzero module is given below.
from logzero import logger logger.debug(“Debug message from your code.”) logger.info(“Info message from your code.”) logger.warning(“Warning message from your code.”) logger.error(“Error message from your code.”)