File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import logging
44import math
55from operator import itemgetter
6+ import queue
67import random
8+ import threading
79import time
810import timeit
911import traceback
10- from types import FrameType , TracebackType
12+ from types import FrameType
1113import unittest
1214from collections import Counter
1315from typing import (
1820 Iterable ,
1921 Iterator ,
2022 List ,
23+ Optional ,
2124 Set ,
2225 Tuple ,
2326 Type ,
@@ -1846,3 +1849,20 @@ def test_ref_cycles(self) -> None:
18461849 ],
18471850 msg = f"the exception's traceback should not contain an exception that captures itself in its own traceback" ,
18481851 )
1852+
1853+ def test_on_queue_in_thread (self ) -> None :
1854+ zeros : List [str ] = []
1855+ src : "queue.Queue[Optional[str]]" = queue .Queue ()
1856+ thread = threading .Thread (
1857+ target = Stream (iter (src .get , None )).foreach (zeros .append )
1858+ )
1859+ thread .start ()
1860+ src .put ("foo" )
1861+ src .put ("bar" )
1862+ src .put (None )
1863+ thread .join ()
1864+ self .assertListEqual (
1865+ zeros ,
1866+ ["foo" , "bar" ],
1867+ msg = "stream must work on Queue" ,
1868+ )
You can’t perform that action at this time.
0 commit comments