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

查看:49
本文介绍了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.

有时它会给出错误:

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/peripheralshref="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 操作系统.和目录权限是:

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)[GCC 4.4.3] 在 linux2 上

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

推荐答案

当图像位于脚本目录(我使用了我自己的动画 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 和 use 之外,我唯一需要的更改是导入 animate (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 框架的线程有关(另见此处相关内容).您应该搜索错误字符串以查看是否可以获得更多信息或以错误字符串为主题提出有关 SO 的特定问题.噗!有已经有

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天全站免登陆