title: Handled signal in Python causes FTP connection to interrupt
body: <p>This scripts checks an FTP and download files at scheduled intervals.</p>
  
  <p>Sending to it the right signal (SIGUSR1) should make it close gracefully, waiting checkAll to complete, if running.</p>
  
  <pre><code>class ScheduledFtpCheck(FtpCheck, Scheduler):
      def __init__(self):
           ...
           self.aborted, self.checking = False, False
  
      def abort(self, *args, **kwargs):
          self.aborted = True
          if not self.checking: self.quit()
  
      def checkAll(self):
          if not self.isAborted():
              self.checking = True
              self.checkAll()
              self.checking = False
              if self.aborted: self.quit()
  
      ...
  
  def main():
      sch = ScheduledFtpCheck()
      signal.signal(signal.SIGUSR1, sch.abort)
      sch.start()
  </code></pre>
  
  <p>the problem is I get a Interrupted system call that makes ftplib.FTP exit prematurely:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/root/my-applications/sensor/sensor/lib/importutils2.py", line 137, in connectAndCheckAll
      try: self.checkAll()
    ...
    File "/usr/lib/python2.6/ftplib.py", line 182, in getline
      line = self.file.readline()
    File "/usr/lib/python2.6/socket.py", line 406, in readline
      data = self._sock.recv(self._rbufsize)
  error: [Errno 4] Interrupted system call
  </code></pre>
  
  <p>So my script handles signal correctly but scheduled check don't.</p>
  
  <p>Why? How can I prevent it?</p>
  
  <p>Thanks for your support</p>