Explicitly close smartdevice during shutdown

This commit is contained in:
Kovid Goyal 2026-02-17 15:41:27 +05:30
parent 7121d29281
commit 14f49ea4cc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 5 deletions

View File

@ -14,13 +14,12 @@ import random
import select
import socket
import sys
import threading
import time
import traceback
from collections import defaultdict
from errno import EAGAIN, EINTR
from functools import wraps
from threading import Thread
from threading import RLock, Thread
from calibre import prints
from calibre.constants import DEBUG, cache_dir, numeric_version
@ -62,8 +61,7 @@ def synchronous(tlockname):
class ConnectionListener(Thread):
def __init__(self, driver):
Thread.__init__(self)
self.daemon = True
super().__init__(name='SmartDeviceConnectionListener', daemon=True)
self.driver = driver
self.keep_running = True
self.all_ip_addresses = {}
@ -384,7 +382,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
}
def __init__(self, path):
self.sync_lock = threading.RLock()
self.sync_lock = RLock()
self.noop_counter = 0
self.noop_time = time.monotonic()
self.debug_start_time = time.time()

View File

@ -1242,6 +1242,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
st = monotonic()
timed_print('Shutdown starting...')
self.shutting_down = True
if (dm := self.device_manager).is_running('smartdevice'):
dm.stop_plugin('smartdevice')
if hasattr(self.library_view, 'connect_to_book_display_timer'):
self.library_view.connect_to_book_display_timer.stop()
self.shutdown_started.emit()