title: python: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0
body: <p>I am trying to read some Images(and later intend to do some task on them), and while Images are being read into memory. I want to display a animated '.gif' Image. For that purpose I had to use Threads. Now it is giving Error :</p>
  
  <pre><code>python: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
  </code></pre>
  
  <p>And some times it gives Error :</p>
  
  <pre><code>python: Fatal IO error 0 (Success) on X server :0.0.
  </code></pre>
  
  <p>(Yes Error message changes almost alternately)
  I have no idea as to why this error Occurred and how to remove it.</p>
  
  <pre><code>import wx
  from wx import animate
  import thread
  import os
  class AniGif(wx.Dialog):
     def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title, size=(300, 300))
        buttonOk = wx.Button(self, id=3, label="Ok", pos=(75, 50), size=(50, 50))
        self.Bind(wx.EVT_BUTTON, self.OnClick, id=3)
  
     def OnClick(self, event) :
        clock = "loading.gif"
        showclock = wx.animate.GIFAnimationCtrl(self, -1, clock)
        showclock.Play()
        thread.start_new_thread(grabImages, ( ))
  
  def grabImages():
      global dirim
      dirim = {}
      path = './images/soccer/'
      listing = os.listdir(path)
      for infile in listing:
          if len(infile)&gt;4 and infile[-4:]=='.jpg' :
              print path+infile
              dirim[infile]=wx.Bitmap(path+infile)
  
  app = wx.App()
  dia = AniGif(None, -1, "Ani Gif")
  dia.ShowModal()
  dia.Destroy()
  app.MainLoop()
  </code></pre>
  
  <p>if I replace this line </p>
  
  <pre><code>dirim[infile]=wx.Bitmap(path+infile)
  </code></pre>
  
  <p>with a dummy line :</p>
  
  <pre><code>dirim[infile]=infile
  </code></pre>
  
  <p>It work's fine , No Error.</p>
  
  <p>And if I replace this line </p>
  
  <pre><code>thread.start_new_thread(grabImages, ( ))
  </code></pre>
  
  <p>with a something like  :</p>
  
  <pre><code>grabImages()
  </code></pre>
  
  <p>It work's fine , No Error. Only Problem I am not able to display animated gif then ..</p>
  
  <p>I have tried removing ~/.gconf/desktop/gnome/peripherals as mentioned in the <a href="https://stackoverflow.com/q/2151937/636475">link</a> given by <a href="https://stackoverflow.com/users/308903/joaquin">joaquin</a>. It doesn't work ..
  and I also tried 'xhost +' . I found from somewhere on the net. Still no success.</p>
  
  <p>Please tell what is happening in this code .. and suggest a solution
  I am using ubuntu 10.04 OS.
  And directory permissions are :</p>
  
  <pre><code>drwxr-xr-x images
  drwxr-xr-x soccer
  </code></pre>
  
  <p>Python verion's detail are :
  Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
  [GCC 4.4.3] on linux2</p>