Category : multithreading

In this video, he shows how multithreading runs on physical(Intel or AMD) processor cores. https://youtu.be/ecKWiaHCEKs and is python capable of running on multiple cores? All these links basically say: Python threads cannot take advantage of many physical cores. This is due to an internal implementation detail called the GIL (global interpreter lock) and if we ..

Read more

I know there are lots of questions over Threading vs Processing; I understand some basics of both of them and advantages and disadvantages of using either of those; the problem started when having this script: from multiprocessing import Process from threading import Thread from time import sleep LOGO = """ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@********************************************************@@@@ @@@@**********************************************************@@@ @@@@**********************************************************@@@ @@@@**********************************************************@@@ ..

Read more

I’m writing a simple class for caching messages from users with time-to-live using expiringdict.To interact with telegram I’m using pyTelegramBotAPI. The class for caching: import threading from expiringdict import ExpiringDict class SmartCacher: PREFIX_SINGLE_UNIT_CH_RU = "ch_ru_single_" PREFIX_SINGLE_UNIT_IN_PSEUDO_BUNCH_CH_RU = "ch_ru_pseudo_bunch_single_" PREFIX_SINGLE_UNIT_IN_MUL_TRAN_CH_RU = "ch_ru_mul_tran_single_" PREFIX_SINGLE_UNIT_RU_CH = "ru_ch_single_" PREFIX_SINGLE_UNIT_IN_MUL_TRAN_RU_CH = "ru_ch_mul_tran_single_" def __init__(self, max_cache_len: int=100, max_cache_time_to_live: int=60): self._rlock = ..

Read more