looks like this:
Thread 1: Populates a list:
LIST.extend(new_items_to_be_processed)
Thread 2: Consumes the list in chunks and removes them from the list:
chunk = LIST[:]
del LIST[:len(chunk)]
do_stuff(chunk)
Would you consider this thread-safe? Any better ways to do it?
I think what you want is to use the queue module in the standard library
will it be thread safe as you do insert and delete operations which are opposite in same variable
I'm not entirely sure. queue seems to be geared more towards single element operations. I'm more interested in bulk operations.
Could you explain further? I suppose you could get and put multiple elements in the queue, albeit "manually"
Обсуждают сегодня