Python: Fatal IO error 11 (resource temporarily unavailable) on server X: 0.0

I try to read some images (and later intend to do some kind of task for them), and so far the images are read in memory. I want to display an animated .gif image. For this I had to use Threads. Now it gives an error:

python: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0. 

And several times this gives an error:

 python: Fatal IO error 0 (Success) on X server :0.0. 

(Yes. The error message changes almost in turn) I do not know why this error occurred and how to remove it.

 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)>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() 

if i replace this line

 dirim[infile]=wx.Bitmap(path+infile) 

with dummy line:

 dirim[infile]=infile 

It works fine, no error.

And if I replace this line

 thread.start_new_thread(grabImages, ( )) 

with something like:

 grabImages() 

It works great, No Error. Only problem: I cannot display an animated gif, then ..

I tried to remove ~ / .gconf / desktop / gnome / peripherals as indicated in the link provided by joaquin . This does not work. and I also tried xhost +. I found it from somewhere on the net. Still no success.

Tell what happens in this code .. and suggest a solution. I am using ubuntu 10.04 OS. And directory rights:

 drwxr-xr-x images drwxr-xr-x soccer 

Python verion details: Python 2.6.5 (r265: 79063, 04.16.2010, 13:09:56) [GCC 4.4.3] on linux2

+6
source share
2 answers

Your code works fine for me in win7 with wxpython 2.8.12.1 and python 2.6.7 running on Spe version 0.8.4.i when the images are in the script directory (I used my own animated gif and PNG).

The only change I needed was to import the animation ( from wx import animate ) in addition to wx and use

 showclock = animate.GIFAnimationCtrl(self, -1, clock) 

instead

 showclock = wx.animate.GIFAnimationCtrl(self, -1, clock) 

Edit: There are several cases where people have the same error messages, such as here and here and here . This last one makes me think that this may be due to the use of streams with the gui map in linux ( see also something related here ). You must google the error line to find out if you can get more information or ask a specific question about SO with the error line as an object. Phew! there is already one !

+2
source

I don’t know if this is related to your problem, but you should create an instance of the dialog box and call it ShowModal after creating wxApp:

 class App(wx.App): def OnInit(self): dia = AniGif(None, -1, "Ani Gif") try: dia.ShowModal() finally: dia.Destroy() return True App(0).MainLoop() 

== edit ==

I have not seen you create an instance of wx.Bitmap from another thread. This is bad. Try instead:

 def grabImages(): global dirim dirim = {} def addToDict(key, path): dirim[key] = wx.Bitmap(path) path = './images/soccer/' listing = os.listdir(path) for infile in listing: if len(infile)>4 and infile[-4:]=='.jpg' : print path+infile wx.CallAfter(addToDict, infile, path+infile) 
+2
source

Source: https://habr.com/ru/post/902421/


All Articles