()
| 244 | |
| 245 | |
| 246 | def test_FusedIpcQueue(): |
| 247 | producer_queue = FusedIpcQueue(is_server=True, fuse_message=False) |
| 248 | consumer_queue = FusedIpcQueue(is_server=False, |
| 249 | address=producer_queue.address, |
| 250 | fuse_message=False) |
| 251 | |
| 252 | def producer(queue: FusedIpcQueue, n: int): |
| 253 | for i in range(n): |
| 254 | queue.put(i) |
| 255 | queue.put(None) |
| 256 | |
| 257 | def consumer(queue: FusedIpcQueue): |
| 258 | to_continue = True |
| 259 | while to_continue: |
| 260 | item = queue.get() |
| 261 | item = [item] if not isinstance(item, list) else item |
| 262 | |
| 263 | for i in item: |
| 264 | if i is None: |
| 265 | to_continue = False |
| 266 | break |
| 267 | print(f"consumer got {i}") |
| 268 | |
| 269 | producer_thread = threading.Thread(target=producer, |
| 270 | args=(producer_queue, 10)) |
| 271 | consumer_thread = threading.Thread(target=consumer, args=(consumer_queue, )) |
| 272 | |
| 273 | producer_thread.start() |
| 274 | consumer_thread.start() |
| 275 | |
| 276 | producer_thread.join() |
| 277 | consumer_thread.join() |
| 278 | |
| 279 | |
| 280 | def create_rsp(id, finished: bool = False): |
no test coverage detected