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 1
1
import asyncio
2
+ from contextlib import suppress
2
3
import datetime
3
4
import logging
4
5
import math
5
6
from operator import itemgetter
7
+ import queue
6
8
import random
9
+ import threading
7
10
import time
8
11
import timeit
9
12
import traceback
10
- from types import FrameType , TracebackType
13
+ from types import FrameType
11
14
import unittest
12
15
from collections import Counter
13
16
from typing import (
18
21
Iterable ,
19
22
Iterator ,
20
23
List ,
24
+ Optional ,
21
25
Set ,
22
26
Tuple ,
23
27
Type ,
@@ -1846,3 +1850,20 @@ def test_ref_cycles(self) -> None:
1846
1850
],
1847
1851
msg = f"the exception's traceback should not contain an exception that captures itself in its own traceback" ,
1848
1852
)
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