Domanda

I'm using the PyUserInput python library that takes advantage of the python xlib library. When I use the mouse movements, I will randomly get an error. Reproduced here:

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!

The only way I've been able to reproduce this is through trial and error. It always happens but it occurs at random times.

È stato utile?

Soluzione

The reason this was occurring seems to be through some threading issue. Looking into the error I realized that the error was not with the PyUserInput module but with the python-xlib module itself. Redefining my search revealed some possible issues with multi-threaded concurrency (which my program uses). This thread, https://code.google.com/p/pywo/issues/detail?id=12#makechanges, suggested importing Xlib.threaded and like the user in the link, I haven't seen the error since.

import Xlib.threaded
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top