@@ -261,15 +261,12 @@ async def test_parking_lot_breaker_basic() -> None:
261
261
# breaking the lot again with the same task is a no-op
262
262
lot .break_lot ()
263
263
264
+ # registering a task as a breaker on an already broken lot is a no-op.
264
265
child_task = None
265
- with pytest .warns (RuntimeWarning ):
266
- async with trio .open_nursery () as nursery :
267
- child_task = await nursery .start (dummy_task )
268
- # registering a task as breaker on an already broken lot is fine... though it
269
- # maybe shouldn't be as it will always cause a RuntimeWarning???
270
- # Or is this a sign that we shouldn't raise a warning?
271
- add_parking_lot_breaker (child_task , lot )
272
- nursery .cancel_scope .cancel ()
266
+ async with trio .open_nursery () as nursery :
267
+ child_task = await nursery .start (dummy_task )
268
+ add_parking_lot_breaker (child_task , lot )
269
+ nursery .cancel_scope .cancel ()
273
270
274
271
# manually breaking a lot with an already exited task is fine
275
272
lot = ParkingLot ()
@@ -293,37 +290,21 @@ async def test_parking_lot_breaker_warnings() -> None:
293
290
lot .break_lot (child_task )
294
291
nursery .cancel_scope .cancel ()
295
292
296
- # note that this get put into an exceptiongroup if inside a nursery, making any
297
- # stacklevel arguments irrelevant
298
- with RaisesGroup (Matcher (RuntimeWarning , match = warn_str )):
299
- async with trio .open_nursery () as nursery :
300
- child_task = await nursery .start (dummy_task )
301
- lot .break_lot (child_task )
302
- nursery .cancel_scope .cancel ()
303
-
304
293
# and doesn't change broken_by
305
294
assert lot .broken_by == task
306
295
307
296
# register multiple tasks as lot breakers, then have them all exit
297
+ # No warning is given on task exit, even if the lot is already broken.
308
298
lot = ParkingLot ()
309
299
child_task = None
310
- # This does not give an exception group, as the warning is raised by the nursery
311
- # exiting, and not any of the tasks inside the nursery.
312
- # And we only get a single warning because... of the default warning filter? and the
313
- # location being the same? (because I haven't figured out why stacklevel makes no
314
- # difference)
315
- with pytest .warns (
316
- RuntimeWarning ,
317
- match = warn_str ,
318
- ):
319
- async with trio .open_nursery () as nursery :
320
- child_task = await nursery .start (dummy_task )
321
- child_task2 = await nursery .start (dummy_task )
322
- child_task3 = await nursery .start (dummy_task )
323
- add_parking_lot_breaker (child_task , lot )
324
- add_parking_lot_breaker (child_task2 , lot )
325
- add_parking_lot_breaker (child_task3 , lot )
326
- nursery .cancel_scope .cancel ()
300
+ async with trio .open_nursery () as nursery :
301
+ child_task = await nursery .start (dummy_task )
302
+ child_task2 = await nursery .start (dummy_task )
303
+ child_task3 = await nursery .start (dummy_task )
304
+ add_parking_lot_breaker (child_task , lot )
305
+ add_parking_lot_breaker (child_task2 , lot )
306
+ add_parking_lot_breaker (child_task3 , lot )
307
+ nursery .cancel_scope .cancel ()
327
308
328
309
# trying to register an exited task as lot breaker errors
329
310
with pytest .raises (
@@ -333,7 +314,7 @@ async def test_parking_lot_breaker_warnings() -> None:
333
314
add_parking_lot_breaker (child_task , lot )
334
315
335
316
336
- async def test_parking_lot_breaker () -> None :
317
+ async def test_parking_lot_breaker_bad_parker () -> None :
337
318
async def bad_parker (lot : ParkingLot , scope : _core .CancelScope ) -> None :
338
319
add_parking_lot_breaker (current_task (), lot )
339
320
with scope :
0 commit comments