mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
Fixes #2004083 [wireless device connection waiting time is too short](https://bugs.launchpad.net/calibre/+bug/2004083)
This commit is contained in:
commit
20de91c75e
@ -232,7 +232,6 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
# Some network protocol constants
|
# Some network protocol constants
|
||||||
BASE_PACKET_LEN = 4096
|
BASE_PACKET_LEN = 4096
|
||||||
PROTOCOL_VERSION = 1
|
PROTOCOL_VERSION = 1
|
||||||
MAX_CLIENT_COMM_TIMEOUT = 300.0 # Wait at most N seconds for an answer
|
|
||||||
MAX_UNSUCCESSFUL_CONNECTS = 5
|
MAX_UNSUCCESSFUL_CONNECTS = 5
|
||||||
|
|
||||||
SEND_NOOP_EVERY_NTH_PROBE = 5
|
SEND_NOOP_EVERY_NTH_PROBE = 5
|
||||||
@ -575,9 +574,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
|
|
||||||
def _read_binary_from_net(self, length):
|
def _read_binary_from_net(self, length):
|
||||||
try:
|
try:
|
||||||
self.device_socket.settimeout(self.MAX_CLIENT_COMM_TIMEOUT)
|
|
||||||
v = self.device_socket.recv(length)
|
v = self.device_socket.recv(length)
|
||||||
self.device_socket.settimeout(None)
|
|
||||||
return v
|
return v
|
||||||
except:
|
except:
|
||||||
self._close_device_socket()
|
self._close_device_socket()
|
||||||
@ -615,12 +612,10 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
total_len = len(s)
|
total_len = len(s)
|
||||||
while sent_len < total_len:
|
while sent_len < total_len:
|
||||||
try:
|
try:
|
||||||
sock.settimeout(self.MAX_CLIENT_COMM_TIMEOUT)
|
|
||||||
if sent_len == 0:
|
if sent_len == 0:
|
||||||
amt_sent = sock.send(s)
|
amt_sent = sock.send(s)
|
||||||
else:
|
else:
|
||||||
amt_sent = sock.send(s[sent_len:])
|
amt_sent = sock.send(s[sent_len:])
|
||||||
sock.settimeout(None)
|
|
||||||
if amt_sent <= 0:
|
if amt_sent <= 0:
|
||||||
raise OSError('Bad write on socket')
|
raise OSError('Bad write on socket')
|
||||||
sent_len += amt_sent
|
sent_len += amt_sent
|
||||||
|
Loading…
x
Reference in New Issue
Block a user