Package: sfdevtoolslight
How to publish to pypi# set up pypi tokenpoetryconfigpypi-token.pypimy-token# build the projectpoetrybuild# publish the projectpoetrypublish# DONEGenerate source code from protobuf$poetryaddgrpcio-tools
$poetryaddgrpcio
$cdsfdevtools/
$poetryrunpython-mgrpc_tools.protoc-I./grpc_protos--python_out=./grpc_protos/--grpc_python_out=./grpc_protos/./grpc_protos/peacock.protoDemo exampleDouble check lock for singletonimportsfdevtools.observability.log_helperaslhimportlogginglogger=lh.init_logger(logger_name="sfdevtools_logger",is_json_output=False)# create class XclassX(SDC):pass# create class YclassY(SDC):passA1,A2=X.instance(),X.instance()B1,B2=Y.instance(),Y.instance()assertA1isnotB1assertA1isA2assertB1isB2logger.info('A1 :{}'.format(A1))logger.info('A2 :{}'.format(A2))logger.info('B1 :{}'.format(B1))logger.info('B2 :{}'.format(B2))Send log to logstashlogger=lh.init_logger(logger_name="connection_tester_logger",is_json_output=False,is_print_to_console=True,is_print_to_logstash=True,logstash_host="<the host name>",logstash_port=5960,logstash_user_tags=["Test001","Test002"])logger.info("Test Message from test")logger.error("Test Message from test")logger.warning("Test Message from test")Simple function poolimportsfdevtools.observability.log_helperaslhimportsfdevtools.devTools.FuncFifoQasFuncFifoQfromfunctoolsimportpartialfromtimeimportsleeplogger=lh.init_logger(logger_name="test_func_fifo_q",is_print_to_console=True,is_json_output=False)func_q:FuncFifoQ.FuncFifoQ=FuncFifoQ.FuncFifoQ(logger=logger,pool_size=10)func_q.start_q()foriinrange(10):func_q.push_func(partial(self.__func_test_foo,i,"hi"))logger.info("Before sleep")sleep(2)logger.info("After sleep")func_q.stop_q()Expected output:2023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:test_func_fifo_q:144][MainThread:92105]Beforesleep2023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:__func_test_foo:151][Thread-4:92105]Hifromthread:02023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:__func_test_foo:151][Thread-8:92105]Hifromthread:12023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:__func_test_foo:151][Thread-3:92105]Hifromthread:22023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:__func_test_foo:151][Thread-2:92105]Hifromthread:32023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:__func_test_foo:151][Thread-9:92105]Hifromthread:42023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:__func_test_foo:151][Thread-5:92105]Hifromthread:52023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:__func_test_foo:151][Thread-7:92105]Hifromthread:62023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:__func_test_foo:151][Thread-10:92105]Hifromthread:72023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:__func_test_foo:151][Thread-6:92105]Hifromthread:82023-02-1313:50:48,565[INFO][test_func_fifo_q][test_sfdevtools.py:__func_test_foo:151][Thread-1:92105]Hifromthread:92023-02-1313:50:50,565[INFO][test_func_fifo_q][test_sfdevtools.py:test_func_fifo_q:146][MainThread:92105]Aftersleep2023-02-1313:50:50,566[INFO][test_func_fifo_q][FuncFifoQ.py:main:56][Thread-7:92105]End2023-02-1313:50:50,566[INFO][test_func_fifo_q][FuncFifoQ.py:main:56][Thread-5:92105]End2023-02-1313:50:50,566[INFO][test_func_fifo_q][FuncFifoQ.py:main:56][Thread-4:92105]End2023-02-1313:50:50,566[INFO][test_func_fifo_q][FuncFifoQ.py:main:56][Thread-10:92105]End2023-02-1313:50:50,567[INFO][test_func_fifo_q][FuncFifoQ.py:main:56][Thread-1:92105]End2023-02-1313:50:50,567[INFO][test_func_fifo_q][FuncFifoQ.py:main:56][Thread-3:92105]End2023-02-1313:50:50,567[INFO][test_func_fifo_q][FuncFifoQ.py:main:56][Thread-8:92105]End2023-02-1313:50:50,568[INFO][test_func_fifo_q][FuncFifoQ.py:main:56][Thread-6:92105]End2023-02-1313:50:50,568[INFO][test_func_fifo_q][FuncFifoQ.py:main:56][Thread-2:92105]End2023-02-1313:50:50,568[INFO][test_func_fifo_q][FuncFifoQ.py:main:56][Thread-9:92105]End