Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python:X服务器上的致命IO错误11(资源暂时不可用):0.0_Python_Multithreading_Wxpython_Animated Gif - Fatal编程技术网

python:X服务器上的致命IO错误11(资源暂时不可用):0.0

python:X服务器上的致命IO错误11(资源暂时不可用):0.0,python,multithreading,wxpython,animated-gif,Python,Multithreading,Wxpython,Animated Gif,我试图阅读一些图像(后来打算对它们执行一些任务),同时图像被读入内存。我想显示一个动画“.gif”图像。为此,我不得不使用线程。现在它给出了一个错误: python: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0. 有时会出现错误: python: Fatal IO error 0 (Success) on X server :0.0. (是错误消息几乎交替更改) 我不知道为什么会发生此错误以及如何

我试图阅读一些图像(后来打算对它们执行一些任务),同时图像被读入内存。我想显示一个动画“.gif”图像。为此,我不得不使用线程。现在它给出了一个错误:

python: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
有时会出现错误:

python: Fatal IO error 0 (Success) on X server :0.0.
(是错误消息几乎交替更改) 我不知道为什么会发生此错误以及如何删除它

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)
thread.start_new_thread(grabImages, ( ))
使用虚拟线:

dirim[infile]=infile
它工作正常,没有错误

如果我换掉这条线

dirim[infile]=wx.Bitmap(path+infile)
thread.start_new_thread(grabImages, ( ))
用一个类似于:

grabImages()
它工作正常,没有错误。唯一的问题是我无法显示动画gif

我已尝试删除~/.gconf/desktop/gnome/peripherals,如给定的中所述。它不起作用。。 我还尝试了“xhost+”。我在网上的某个地方找到的。仍然没有成功

请告诉我这段代码中发生了什么。。并提出解决方案 我使用的是ubuntu 10.04操作系统。 和目录权限为:

drwxr-xr-x images
drwxr-xr-x soccer
Python verion的详细信息如下: Python 2.6.5(r265:79063,2010年4月16日,13:09:56)
[GCC 4.4.3]在linux2上,当图像位于脚本目录中时(我使用自己的动画gif和png),您的代码在win7中非常适合我,wxpython 2.8.12.1和python 2.6.7在Spe版本0.8.4.i上运行

除了wx和使用外,我唯一需要的更改是导入animate(
自wx导入animate

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

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

编辑:有些人的错误信息与您的相同,例如和。最后一个问题让我认为它可能与在linux()中使用带有gui框架的线程有关。你应该用谷歌搜索错误字符串,看看你是否可以得到更多的信息,或者问一个特殊的问题,以错误字符串为主题。Uf!有

不知道它是否与您的问题有关,但您应该实例化该对话框,并在创建wxApp后调用其ShowModal:

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

App(0).MainLoop()
==编辑==

我没有看到您从另一个线程实例化wx.Bitmap。这很糟糕。请尝试以下方法:

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)

目录权限为:drwxr-xr-x images drwxr-xr-x soccer它不是受保护的目录或服务器。导入是:导入wx,wx.animate导入线程导入操作系统我正在使用ubuntu 10.04根据你的建议,我编辑了代码:它给出:name错误:未定义全局名称“animate”anshul@anshul-笔记本电脑:~/project$python gif3.py./images/soccer/0.jpg python:X服务器上的致命IO错误0(成功):0.0。anshul@anshul-笔记本电脑:~/project$python gif3.py./images/soccer/0.jpg python:X服务器上的致命IO错误11(资源暂时不可用):0.0。anshul@anshul-笔记本电脑:~/project$python gif3.py./images/soccer/0.jpg python:X服务器上的致命IO错误0(成功):0.0错误消息交替更改(:神秘)…:|它仍然显示相同的两个错误:致命IO错误0致命IO错误11@anshul410即使使用
CallAfter
?这为我解决了一个类似的问题。几年后出现了这个问题,但我想补充一点,我也有同样的错误(但是PySide),对我来说,它与。所以基本上你不能在主线程之外调用draw函数,这就是为什么当你用其他东西替换位图时它能工作的原因。