的Python:X服务器上的致命IO错误11(资源暂时不可用):0.0 [英] python: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0

查看:776
本文介绍了的Python:X服务器上的致命IO错误11(资源暂时不可用):0.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试读取一些图像(后来打算对它们执行一些任务),并且正在将图像读取到内存中.我想显示一个动画的".gif"图像.为此,我不得不使用线程.现在出现错误:

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 :

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

有时它会给出错误消息:

And some times it gives Error :

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

(是,错误消息几乎交替更改) 我不知道为什么会发生此错误以及如何将其删除.

(Yes Error message changes almost alternately) I have no idea as to 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()

如果我替换此行

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

带有空行:

dirim[infile]=infile

这很好,没有错误.

如果我替换此行

thread.start_new_thread(grabImages, ( ))

带有类似这样的内容:

grabImages()

它很好,没有错误.唯一的问题是我当时无法显示动画gif.

It work's fine , No Error. Only Problem I am not able to display animated gif then ..

我已尝试删除链接中提到的〜/.gconf/desktop/gnome/peripherals. href ="https://stackoverflow.com/users/308903/joaquin"> joaquin .这是行不通的.. 我也尝试了'xhost +'.我从网上某处发现.仍然没有成功.

I have tried removing ~/.gconf/desktop/gnome/peripherals as mentioned in the link given by joaquin. It doesn't work .. and I also tried 'xhost +' . I found from somewhere on the net. Still no success.

请告诉此代码中正在发生的事情..并提出解决方案 我正在使用ubuntu 10.04 OS. 目录权限为:

Please tell what is happening in this code .. and suggest a solution I am using ubuntu 10.04 OS. And directory permissions are :

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

Python版本的详细信息是: Python 2.6.5(r265:79063,2010年4月16日,13:09:56) linux2上的[GCC 4.4.3]

Python verion's detail are : Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2

推荐答案

当图像位于以下位置时,在Spe版本0.8.4.i上运行的wxpython 2.8.12.1和python 2.6.7在win7中,您的代码对我来说是完美的.脚本目录(我使用了自己的动画gif和png).

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

我唯一需要做的更改是除wx之外还导入动画(from wx import animate)并使用

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

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

代替

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

编辑:在某些情况下,人们会遇到与您相同的错误消息,例如 此处.这最后一个使我认为这可能与在Linux中使用带有gui框架的线程有关(已经存在

There are several cases of people having the same error messsages as yours like here and here and here. This last one makes me think that it could be related with the use of threads with a gui framework in linux (see also here something related). You should google the error string to see if you can get some more information or ask an especific question on SO with the error string as the subject. Uf! there is already one !

这篇关于的Python:X服务器上的致命IO错误11(资源暂时不可用):0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆