ARTICLE AD BOX
def ingestion_worker(write_queue):
try:
curr_thread = threading.current_thread()
while not STOP_EVENT.is_set():
console_logger.info(f"STOP_EVENT is set {STOP_EVENT.is_set()}, running {curr_thread.name}")
tick = write_queue.get()
if tick is None:
continue
else:
with BUFF_LOCK:
m_tick = {
tick['instrument_token'],
datetime.now().stfrtime("%Y-%m-%d %H:%M:%S"),
tick['last_price'],
tick['volume']
}
BUFFER.append(m_tick)
finally:
console_logger.info(f"STOP_EVENT is set {STOP_EVENT.is_set()}, stopping {curr_thread.name}")
I have been trying to build a ingestion function which picks up feed from a websocket, so I'm planning to run this function on a separate thread, my question is since I'm running this function a separate thread with a tightly blocked while loop, does it block the GIL?i.e do my other threads just wait around forever?
(Correct me if I'm using wrong jargons or terminology, also if anyone could provide a general advice how I can build this better, it would be much helpful!)
