Abstract
There is a race in put, and the use_sudo=True, and writing a file with the same content from multiple connections concurrently.
Steps To Reproduce
Run this script concurrently:
import os, itertools, StringIO
from fabric.api import task, run, put, settings
@task
def megaput():
content = '0' * 1024
with settings(host_string = '127.0.0.1', user = os.environ['USER']):
run('mkdir -p /tmp/megaput')
for i in itertools.count():
put(StringIO.StringIO(content), '/tmp/megaput/file', use_sudo = True)
print 'copied', i, 'times'
It seems that the name of temporary file created is a hash of the host string and the file content. When puting files with the same content to the same host, there is a race for the mv operation, and with non-zero probability only the first operation will succeed.
Adding a random string to https://github.com/fabric/fabric/blob/master/fabric/sftp.py#L164 seems to make this script work without problems (e.g. hasher.update(uuid.uuid4().hex)).
Abstract
There is a race in
put, and theuse_sudo=True, and writing a file with the same content from multiple connections concurrently.Steps To Reproduce
Run this script concurrently:
It seems that the name of temporary file created is a hash of the host string and the file content. When
puting files with the same content to the same host, there is a race for themvoperation, and with non-zero probability only the first operation will succeed.Adding a random string to https://github.com/fabric/fabric/blob/master/fabric/sftp.py#L164 seems to make this script work without problems (e.g.
hasher.update(uuid.uuid4().hex)).