@@ -415,59 +415,48 @@ def closed(self) -> bool:
415
415
"""Return True if the manager is closed."""
416
416
return not self ._subscription or self ._subscription .transport .client .is_closed
417
417
418
- @abstractmethod
419
- async def _start (self ) -> float :
420
- """Setup the processor.
421
-
422
- Returns the next renewal call at time.
423
-
424
- """
425
-
426
- async def _set_synchronization_point (self , service : ONVIFService ) -> float :
427
- """Set the synchronization point."""
428
- try :
429
- await service .SetSynchronizationPoint ()
430
- except (Fault , asyncio .TimeoutError , TransportError , TypeError ):
431
- logger .debug ("%s: SetSynchronizationPoint failed" , self ._service .url )
432
-
433
418
async def start (self ) -> None :
434
- """Setup the notification processor ."""
419
+ """Setup the manager ."""
435
420
renewal_call_at = await self ._start ()
436
421
self ._schedule_subscription_renew (renewal_call_at )
437
422
return self ._subscription
438
423
439
424
def pause (self ) -> None :
440
- """Pause the notification processor ."""
425
+ """Pause the manager ."""
441
426
self ._cancel_renewals ()
442
427
443
428
def resume (self ) -> None :
444
- """Resume the notification processor ."""
429
+ """Resume the manager ."""
445
430
self ._schedule_subscription_renew (self ._loop .time ())
446
431
447
432
async def stop (self ) -> None :
448
- """Stop the notification processor ."""
433
+ """Stop the manager ."""
449
434
logger .debug ("%s: Stop the notification manager" , self ._device .host )
450
435
self ._cancel_renewals ()
451
436
assert self ._subscription , "Call start first"
452
437
await self ._subscription .Unsubscribe ()
453
438
454
439
async def shutdown (self ) -> None :
455
- """Shutdown the notification processor."""
440
+ """Shutdown the manager.
441
+
442
+ This method is irreversible.
443
+ """
456
444
self ._shutdown = True
457
445
if self ._restart_or_renew_task :
458
446
self ._restart_or_renew_task .cancel ()
459
447
logger .debug ("%s: Shutdown the notification manager" , self ._device .host )
460
448
await self .stop ()
461
449
462
- async def renew (self ) -> float :
463
- """Renew the notification subscription."""
464
- device = self ._device
465
- logger .debug ("%s: Renew the notification manager" , device .host )
466
- return self ._calculate_next_renewal_call_at (
467
- await self ._subscription .Renew (
468
- device .get_next_termination_time (self ._interval )
469
- )
470
- )
450
+ @abstractmethod
451
+ async def _start (self ) -> float :
452
+ """Setup the processor. Returns the next renewal call at time."""
453
+
454
+ async def _set_synchronization_point (self , service : ONVIFService ) -> float :
455
+ """Set the synchronization point."""
456
+ try :
457
+ await service .SetSynchronizationPoint ()
458
+ except (Fault , asyncio .TimeoutError , TransportError , TypeError ):
459
+ logger .debug ("%s: SetSynchronizationPoint failed" , self ._service .url )
471
460
472
461
def _cancel_renewals (self ) -> None :
473
462
"""Cancel any pending renewals."""
@@ -516,7 +505,13 @@ async def _restart_subscription(self) -> bool:
516
505
@retry_connection_error ()
517
506
async def _call_subscription_renew (self ) -> float :
518
507
"""Call notify subscription Renew."""
519
- return await self .renew ()
508
+ device = self ._device
509
+ logger .debug ("%s: Renew the notification manager" , device .host )
510
+ return self ._calculate_next_renewal_call_at (
511
+ await self ._subscription .Renew (
512
+ device .get_next_termination_time (self ._interval )
513
+ )
514
+ )
520
515
521
516
async def _renew_subscription (self ) -> float | None :
522
517
"""Renew notify subscription."""
@@ -533,9 +528,7 @@ async def _renew_subscription(self) -> float | None:
533
528
)
534
529
return None
535
530
536
- async def _renew_or_restart_subscription (
537
- self , now : dt .datetime | None = None
538
- ) -> None :
531
+ async def _renew_or_restart_subscription (self ) -> None :
539
532
"""Renew or start notify subscription."""
540
533
if self ._shutdown :
541
534
return
0 commit comments