LINUX.ORG.RU

История изменений

Исправление rtxtxtrx, (текущая версия) :

import threading
lock = threading.Lock()
Empty = object()
it = iter(data)
def worker(it):
  while True:
    with lock:
      item = next(it, Empty)
    if item is Empty:
      break
    # ...

Исходная версия rtxtxtrx, :

import threading
lock = threading.Lock()
Empty = object()
it = iter(data)
def worker(it):
  while True:
    whith lock:
      item = next(it, Empty)
    if item is Empty:
      break
    # ...