File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 11import asyncio
2+ from contextlib import suppress
23import datetime
34import logging
45import math
56from operator import itemgetter
7+ import queue
68import random
9+ import threading
710import time
811import timeit
912import traceback
10- from types import FrameType , TracebackType
13+ from types import FrameType
1114import unittest
1215from collections import Counter
1316from typing import (
1821 Iterable ,
1922 Iterator ,
2023 List ,
24+ Optional ,
2125 Set ,
2226 Tuple ,
2327 Type ,
@@ -1846,3 +1850,20 @@ def test_ref_cycles(self) -> None:
18461850 ],
18471851 msg = f"the exception's traceback should not contain an exception that captures itself in its own traceback" ,
18481852 )
1853+
1854+ def test_on_queue_in_thread (self ) -> None :
1855+ zeros : List [str ] = []
1856+ src : "queue.Queue[Optional[str]]" = queue .Queue ()
1857+ thread = threading .Thread (
1858+ target = Stream (iter (src .get , None )).foreach (zeros .append )
1859+ )
1860+ thread .start ()
1861+ src .put ("foo" )
1862+ src .put ("bar" )
1863+ src .put (None )
1864+ thread .join ()
1865+ self .assertListEqual (
1866+ zeros ,
1867+ ["foo" , "bar" ],
1868+ msg = "stream must work on Queue" ,
1869+ )
You can’t perform that action at this time.
0 commit comments