prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Transferring Files with LocalWorker seems not working
  This ticket is a migrated Trac ticket [3628](http://trac.buildbot.net/ticket/3628)
  
  People contributed to the original ticket: @unknown_contributor, @sa2ajj
  Ticket created on: `Oct 20 2016`
  Ticket last modified on: `Oct 27 2016`
  
  ---
  
  Hi,
  
  I just update my buildbot to 0.9. And i convert my old Slave to [[LocalWorker]].
  
  But now my builds are stuck during the copy process "DirectoryUpload" or "!Multiple[[FileUpload]]"
  
  I check the `twistd.log` and it looks like the first light files are copied but then the copy is stuck during a transfer of 5MB. The file has always a size of 3227648o.
  
  Thanks for your help
  
  
  ---
  
  
  
  
  </issue>
  <code>
  [start of master/buildbot/worker/protocols/null.py]
  1 # This file is part of Buildbot.  Buildbot is free software: you can
  2 # redistribute it and/or modify it under the terms of the GNU General Public
  3 # License as published by the Free Software Foundation, version 2.
  4 #
  5 # This program is distributed in the hope that it will be useful, but WITHOUT
  6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  7 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  8 # details.
  9 #
  10 # You should have received a copy of the GNU General Public License along with
  11 # this program; if not, write to the Free Software Foundation, Inc., 51
  12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  13 #
  14 # Copyright Buildbot Team Members
  15 
  16 from __future__ import absolute_import
  17 from __future__ import division
  18 from __future__ import print_function
  19 
  20 from twisted.internet import defer
  21 from twisted.python import log
  22 
  23 from buildbot.worker.protocols import base
  24 
  25 
  26 class Listener(base.Listener):
  27     pass
  28 
  29 
  30 class ProxyMixin():
  31 
  32     def __init__(self, impl):
  33         assert isinstance(impl, self.ImplClass)
  34         self.impl = impl
  35         self._disconnect_listeners = []
  36 
  37     def callRemote(self, message, *args, **kw):
  38         method = getattr(self.impl, "remote_%s" % message, None)
  39         if method is None:
  40             raise AttributeError("No such method: remote_%s" % (message,))
  41         try:
  42             state = method(*args, **kw)
  43         except TypeError:
  44             log.msg("%s didn't accept %s and %s" % (method, args, kw))
  45             raise
  46         return defer.maybeDeferred(lambda: state)
  47 
  48     def notifyOnDisconnect(self, cb):
  49         pass
  50 
  51     def dontNotifyOnDisconnect(self, cb):
  52         pass
  53 
  54 
  55 # just add ProxyMixin capability to the RemoteCommandProxy
  56 # so that callers of callRemote actually directly call the proper method
  57 class RemoteCommandProxy(ProxyMixin):
  58     ImplClass = base.RemoteCommandImpl
  59 
  60 
  61 class FileReaderProxy(ProxyMixin):
  62     ImplClass = base.FileReaderImpl
  63 
  64 
  65 class FileWriterProxy(ProxyMixin):
  66     ImplClass = base.FileWriterImpl
  67 
  68 
  69 class Connection(base.Connection):
  70     proxies = {base.FileWriterImpl: FileWriterProxy,
  71                base.FileReaderImpl: FileReaderProxy}
  72 
  73     def loseConnection(self):
  74         pass
  75 
  76     def remotePrint(self, message):
  77         return defer.maybeDeferred(self.worker.bot.remote_print, message)
  78 
  79     def remoteGetWorkerInfo(self):
  80         return defer.maybeDeferred(self.worker.bot.remote_getWorkerInfo)
  81 
  82     def remoteSetBuilderList(self, builders):
  83         return defer.maybeDeferred(self.worker.bot.remote_setBuilderList, builders)
  84 
  85     def remoteStartCommand(self, remoteCommand, builderName, commandId, commandName, args):
  86         remoteCommand = RemoteCommandProxy(remoteCommand)
  87         args = self.createArgsProxies(args)
  88         workerforbuilder = self.worker.bot.builders[builderName]
  89         return defer.maybeDeferred(workerforbuilder.remote_startCommand, remoteCommand,
  90                                    commandId, commandName, args)
  91 
  92     def remoteShutdown(self):
  93         return defer.maybeDeferred(self.worker.stopService)
  94 
  95     def remoteStartBuild(self, builderName):
  96         return defer.succeed(self.worker.bot.builders[builderName].remote_startBuild())
  97 
  98     def remoteInterruptCommand(self, builderName, commandId, why):
  99         workerforbuilder = self.worker.bot.builders[builderName]
  100         return defer.maybeDeferred(workerforbuilder.remote_interruptCommand, commandId, why)
  101
  [end of master/buildbot/worker/protocols/null.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/master/buildbot/worker/protocols/null.py b/master/buildbot/worker/protocols/null.py
  --- a/master/buildbot/worker/protocols/null.py
  +++ b/master/buildbot/worker/protocols/null.py
  @@ -20,6 +20,7 @@
   from twisted.internet import defer
   from twisted.python import log
   
  +from buildbot.util.eventual import fireEventually
   from buildbot.worker.protocols import base
   
   
  @@ -43,7 +44,8 @@
           except TypeError:
               log.msg("%s didn't accept %s and %s" % (method, args, kw))
               raise
  -        return defer.maybeDeferred(lambda: state)
  +        # break callback recursion for large transfers by using fireEventually
  +        return fireEventually(state)
   
       def notifyOnDisconnect(self, cb):
           pass
  
verification_info: {"golden_diff": "diff --git a/master/buildbot/worker/protocols/null.py b/master/buildbot/worker/protocols/null.py\n--- a/master/buildbot/worker/protocols/null.py\n+++ b/master/buildbot/worker/protocols/null.py\n@@ -20,6 +20,7 @@\n from twisted.internet import defer\n from twisted.python import log\n \n+from buildbot.util.eventual import fireEventually\n from buildbot.worker.protocols import base\n \n \n@@ -43,7 +44,8 @@\n         except TypeError:\n             log.msg(\"%s didn't accept %s and %s\" % (method, args, kw))\n             raise\n-        return defer.maybeDeferred(lambda: state)\n+        # break callback recursion for large transfers by using fireEventually\n+        return fireEventually(state)\n \n     def notifyOnDisconnect(self, cb):\n         pass\n", "issue": "Transferring Files with LocalWorker seems not working\nThis ticket is a migrated Trac ticket [3628](http://trac.buildbot.net/ticket/3628)\n\nPeople contributed to the original ticket: @unknown_contributor, @sa2ajj\nTicket created on: `Oct 20 2016`\nTicket last modified on: `Oct 27 2016`\n\n---\n\nHi,\n\nI just update my buildbot to 0.9. And i convert my old Slave to [[LocalWorker]].\n\nBut now my builds are stuck during the copy process \"DirectoryUpload\" or \"!Multiple[[FileUpload]]\"\n\nI check the `twistd.log` and it looks like the first light files are copied but then the copy is stuck during a transfer of 5MB. The file has always a size of 3227648o.\n\nThanks for your help\n\n\n---\n\n\n\n", "before_files": [{"content": "# This file is part of Buildbot.  Buildbot is free software: you can\n# redistribute it and/or modify it under the terms of the GNU General Public\n# License as published by the Free Software Foundation, version 2.\n#\n# This program is distributed in the hope that it will be useful, but WITHOUT\n# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\n# details.\n#\n# You should have received a copy of the GNU General Public License along with\n# this program; if not, write to the Free Software Foundation, Inc., 51\n# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n#\n# Copyright Buildbot Team Members\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom twisted.internet import defer\nfrom twisted.python import log\n\nfrom buildbot.worker.protocols import base\n\n\nclass Listener(base.Listener):\n    pass\n\n\nclass ProxyMixin():\n\n    def __init__(self, impl):\n        assert isinstance(impl, self.ImplClass)\n        self.impl = impl\n        self._disconnect_listeners = []\n\n    def callRemote(self, message, *args, **kw):\n        method = getattr(self.impl, \"remote_%s\" % message, None)\n        if method is None:\n            raise AttributeError(\"No such method: remote_%s\" % (message,))\n        try:\n            state = method(*args, **kw)\n        except TypeError:\n            log.msg(\"%s didn't accept %s and %s\" % (method, args, kw))\n            raise\n        return defer.maybeDeferred(lambda: state)\n\n    def notifyOnDisconnect(self, cb):\n        pass\n\n    def dontNotifyOnDisconnect(self, cb):\n        pass\n\n\n# just add ProxyMixin capability to the RemoteCommandProxy\n# so that callers of callRemote actually directly call the proper method\nclass RemoteCommandProxy(ProxyMixin):\n    ImplClass = base.RemoteCommandImpl\n\n\nclass FileReaderProxy(ProxyMixin):\n    ImplClass = base.FileReaderImpl\n\n\nclass FileWriterProxy(ProxyMixin):\n    ImplClass = base.FileWriterImpl\n\n\nclass Connection(base.Connection):\n    proxies = {base.FileWriterImpl: FileWriterProxy,\n               base.FileReaderImpl: FileReaderProxy}\n\n    def loseConnection(self):\n        pass\n\n    def remotePrint(self, message):\n        return defer.maybeDeferred(self.worker.bot.remote_print, message)\n\n    def remoteGetWorkerInfo(self):\n        return defer.maybeDeferred(self.worker.bot.remote_getWorkerInfo)\n\n    def remoteSetBuilderList(self, builders):\n        return defer.maybeDeferred(self.worker.bot.remote_setBuilderList, builders)\n\n    def remoteStartCommand(self, remoteCommand, builderName, commandId, commandName, args):\n        remoteCommand = RemoteCommandProxy(remoteCommand)\n        args = self.createArgsProxies(args)\n        workerforbuilder = self.worker.bot.builders[builderName]\n        return defer.maybeDeferred(workerforbuilder.remote_startCommand, remoteCommand,\n                                   commandId, commandName, args)\n\n    def remoteShutdown(self):\n        return defer.maybeDeferred(self.worker.stopService)\n\n    def remoteStartBuild(self, builderName):\n        return defer.succeed(self.worker.bot.builders[builderName].remote_startBuild())\n\n    def remoteInterruptCommand(self, builderName, commandId, why):\n        workerforbuilder = self.worker.bot.builders[builderName]\n        return defer.maybeDeferred(workerforbuilder.remote_interruptCommand, commandId, why)\n", "path": "master/buildbot/worker/protocols/null.py"}]}