code: def check_ProducerConsumer(PC, jobs):
      def slowprod(n, secs=0.001):
          for i in range(n):
              yield i
              sleep(secs)
  
      def slowcons(i):
          # so takes longer to consume than to produce and progress bar will appear
          # after slowprod is done producing
          sleep(0.002)
          yield from fastcons(i)
  
      def fastcons(i):
          # we should still work correctly if consumer is fast!
          yield {"i": i, "status": "ok" if i % 2 else "error"}
  
      for cons in fastcons, slowcons:
          # sorted since order of completion is not guaranteed
          assert_equal(
              sorted(
                  PC(slowprod(10), cons, jobs=jobs),
                  key=lambda r: r["i"],
              ),
              [
                  {"i": i, "status": "ok" if i % 2 else "error"}
                  for i in range(10)
              ],
          )
  
file_path: datalad/datalad/support/tests/test_parallel.py
imports: import logging
  from functools import partial
  from time import sleep, time
  import pytest
  from datalad import lgr
  from datalad.support import path
  from datalad.support.exceptions import IncompleteResultsError
  from datalad.support.parallel import ProducerConsumer, ProducerConsumerProgressLog, no_parentds_in_futures
  from datalad.tests.utils_pytest import assert_equal, assert_greater, assert_greater_equal, assert_raises, assert_repo_status, known_failure_osx, on_osx, on_windows, rmtree, skip_if, slow, with_tempfile
label_desc: Use image node_id 1 for calling a global function with example usage: check_ProducerConsumer(PC, jobs) without return types