ansible: FileService: don't send empty last chunk
This commit is contained in:
parent
2a56c672ca
commit
e1a3cea2f9
|
@ -378,8 +378,8 @@ class FileService(mitogen.service.Service):
|
||||||
chunks to fill that assumed pipe, then responding to delivery
|
chunks to fill that assumed pipe, then responding to delivery
|
||||||
acknowledgements from the receiver by scheduling new chunks.
|
acknowledgements from the receiver by scheduling new chunks.
|
||||||
|
|
||||||
Transfers proceeed one-at-a-time per stream. When multiple contexts exist
|
Transfers proceed one-at-a-time per stream. When multiple contexts exist on
|
||||||
on a stream (e.g. one is the SSH account, another is a sudo account, and a
|
a stream (e.g. one is the SSH account, another is a sudo account, and a
|
||||||
third is a proxied SSH connection), each request is satisfied in turn
|
third is a proxied SSH connection), each request is satisfied in turn
|
||||||
before subsequent requests start flowing. This ensures when a stream is
|
before subsequent requests start flowing. This ensures when a stream is
|
||||||
contended, priority is given to completing individual transfers rather than
|
contended, priority is given to completing individual transfers rather than
|
||||||
|
@ -423,9 +423,8 @@ class FileService(mitogen.service.Service):
|
||||||
unregistered_msg = 'Path is not registered with FileService.'
|
unregistered_msg = 'Path is not registered with FileService.'
|
||||||
context_mismatch_msg = 'sender= kwarg context must match requestee context'
|
context_mismatch_msg = 'sender= kwarg context must match requestee context'
|
||||||
|
|
||||||
#: Initial burst size. With 1MiB and a RTT of 10ms, maximum throughput is
|
#: Burst size. With 1MiB and 10ms RTT max throughput is 100MiB/sec, which
|
||||||
#: 112MiB/sec, which is 5x what SSH can handle on a 2011 era 2.4Ghz Core
|
#: is 5x what SSH can handle on a 2011 era 2.4Ghz Core i5.
|
||||||
#: i5.
|
|
||||||
window_size_bytes = 1048576
|
window_size_bytes = 1048576
|
||||||
|
|
||||||
def __init__(self, router):
|
def __init__(self, router):
|
||||||
|
@ -498,10 +497,10 @@ class FileService(mitogen.service.Service):
|
||||||
while state.jobs and state.unacked < self.window_size_bytes:
|
while state.jobs and state.unacked < self.window_size_bytes:
|
||||||
sender, fp = state.jobs[0]
|
sender, fp = state.jobs[0]
|
||||||
s = fp.read(mitogen.core.CHUNK_SIZE)
|
s = fp.read(mitogen.core.CHUNK_SIZE)
|
||||||
|
if s:
|
||||||
state.unacked += len(s)
|
state.unacked += len(s)
|
||||||
sender.send(s)
|
sender.send(s)
|
||||||
|
else:
|
||||||
if not s:
|
|
||||||
# File is done. Cause the target's receive loop to exit by
|
# File is done. Cause the target's receive loop to exit by
|
||||||
# closing the sender, close the file, and remove the job entry.
|
# closing the sender, close the file, and remove the job entry.
|
||||||
sender.close()
|
sender.close()
|
||||||
|
@ -516,7 +515,7 @@ class FileService(mitogen.service.Service):
|
||||||
})
|
})
|
||||||
def fetch(self, path, sender, msg):
|
def fetch(self, path, sender, msg):
|
||||||
"""
|
"""
|
||||||
Fetch a file's data.
|
Start a transfer for a registered path.
|
||||||
|
|
||||||
:param str path:
|
:param str path:
|
||||||
File path.
|
File path.
|
||||||
|
@ -532,8 +531,7 @@ class FileService(mitogen.service.Service):
|
||||||
* ``mtime``: Floating point modification time.
|
* ``mtime``: Floating point modification time.
|
||||||
* ``ctime``: Floating point change time.
|
* ``ctime``: Floating point change time.
|
||||||
:raises Error:
|
:raises Error:
|
||||||
Unregistered path, or attempt to send to context that was not the
|
Unregistered path, or Sender did not match requestee context.
|
||||||
requestee context.
|
|
||||||
"""
|
"""
|
||||||
if path not in self._metadata_by_path:
|
if path not in self._metadata_by_path:
|
||||||
raise Error(self.unregistered_msg)
|
raise Error(self.unregistered_msg)
|
||||||
|
|
Loading…
Reference in New Issue