PyUserInput和Xlib崩溃

时间:2014-01-01 20:18:57

标签: python mousemove xlib

我正在使用PyUserInput python库,它利用了python xlib库。当我使用鼠标移动时,我会随机出错。转载于此:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pymouse/x11.py", line 68, in move
    if (x, y) != self.position():
  File "/usr/local/lib/python2.7/dist-packages/pymouse/x11.py", line 76, in position
    coord = self.display.screen().root.query_pointer()._data
  File "/usr/lib/pymodules/python2.7/Xlib/xobject/drawable.py", line 569, in query_pointer
    window = self.id)
  File "/usr/lib/pymodules/python2.7/Xlib/protocol/rq.py", line 1428, in __init__
    self.reply()
  File "/usr/lib/pymodules/python2.7/Xlib/protocol/rq.py", line 1440, in reply
    self._display.send_and_recv(request = self._serial)
  File "/usr/lib/pymodules/python2.7/Xlib/protocol/display.py", line 547, in send_and_recv
    gotreq = self.parse_response(request)
  File "/usr/lib/pymodules/python2.7/Xlib/protocol/display.py", line 634, in parse_response
    gotreq = self.parse_request_response(request) or gotreq
  File "/usr/lib/pymodules/python2.7/Xlib/protocol/display.py", line 711, in parse_request_response
    req = self.get_waiting_replyrequest()
  File "/usr/lib/pymodules/python2.7/Xlib/protocol/display.py", line 838, in get_waiting_replyrequest
    raise RuntimeError("Request reply to unknown request.  Can't happen!")
RuntimeError: Request reply to unknown request.  Can't happen!

我能够重现这一点的唯一方法是通过反复试验。它总是会发生,但它会随机发生。

1 个答案:

答案 0 :(得分:2)

这种情况发生的原因似乎是通过一些线程问题。查看错误,我意识到错误不是PyUserInput模块,而是python-xlib模块本身。重新定义我的搜索揭示了多线程并发(我的程序使用)的一些可能的问题。这个帖子https://code.google.com/p/pywo/issues/detail?id=12#makechanges建议导入Xlib.threaded并且像链接中的用户一样,我从未见过错误。

import Xlib.threaded