(connection, lower, upper, secret)
| 365 | print("Example 22") |
| 366 | @contextlib.asynccontextmanager # Changed |
| 367 | async def new_async_game(connection, lower, upper, secret): # Changed |
| 368 | print( |
| 369 | f"Guess a number between {lower} and {upper}!" |
| 370 | f" Shhhhh, it's {secret}." |
| 371 | ) |
| 372 | await connection.send(f"PARAMS {lower} {upper}") # Changed |
| 373 | try: |
| 374 | yield AsyncClientSession( |
| 375 | connection.send, |
| 376 | connection.receive, |
| 377 | secret, |
| 378 | ) |
| 379 | finally: |
| 380 | # Make it so the output printing is in |
| 381 | # the same order as the threaded version. |
| 382 | await asyncio.sleep(0.1) |
| 383 | await connection.send("CLEAR") # Changed |
| 384 | |
| 385 | |
| 386 | print("Example 23") |
no test coverage detected