#14 Error when using 2 screens

closed-fixed
nobody
None
5
2006-07-19
2005-01-08
bysse
No

This is the error i get when i'm trying to use
python-xlib with 2 screens, but if i'm using 1 screen
the code works:

File "./pythonheadtest.py", line 4, in ?
disp = Display()
File
"/usr/lib/python2.3/site-packages/Xlib/display.py",
line 80, in __init__
self.display = _BaseDisplay(display)
File
"/usr/lib/python2.3/site-packages/Xlib/display.py",
line 67, in __init__
apply(protocol.display.Display.__init__, (self, ) +
args, keys)
File
"/usr/lib/python2.3/site-packages/Xlib/protocol/display.py",
line 122, in __init__
self.default_screen = min(self.default_screen,
len(self.info.roots) - 1)
File
"/usr/lib/python2.3/site-packages/Xlib/protocol/rq.py",
line 1371, in __getattr__
raise AttributeError(attr)
AttributeError: roots

Discussion

  • bysse
    bysse
    2005-01-08

    test program

     
    Attachments
  • Simon Forman
    Simon Forman
    2005-02-04

    Logged In: YES
    user_id=1211654

    self.info is a ConnectionSetupRequest object, its
    _success_reply Struct has a 'roots' rq.List field, but its
    LengthOf field is set to 1
    Perhaps when using two screens the reply from the server
    includes info on both roots, but the parse_binary() for this
    request is still just trying to parse one?
    I hope this helps.
    ~Simon

     
  • Mike Grant
    Mike Grant
    2005-06-10

    Logged In: YES
    user_id=1175208

    I just got this error when using LTool with the 7664 NVIDIA
    drivers (didn't occur with previous revisions). I think I
    managed to track the problem down to an overused variable in
    Xlib/protocol/display.py.

    "recv" is used as a byte counter on line 530 (function
    send_and_recv) as:
    recv = self.socket.recv(2048)
    but this overwrites the function's argument "recv" (used to
    request all pending data be read) and causes the function to
    terminate after only one read iteration. In the case of a
    large reply (> 2048 bytes? such as on connection setup with
    a multihead display) requiring more than one iteration to
    get all the data, this causes the request reply not to be
    parsed.

    Renaming the second use of "recv" to "bytes_recv" (or
    whatever) appears to fix the error for me, e.g.
    if recieving:
    try:
    bytes_recv = self.socket.recv(2048)
    except socket.error, err:
    self.close_internal('server: %s' %
    err[1])
    raise self.socket_error

    if not bytes_recv:
    # Clear up, set a connection closed
    indicator and raise it
    self.close_internal('server')
    raise self.socket_error

    self.data_recv = self.data_recv + bytes_recv
    gotreq = self.parse_response(request)

    As a minor aside, I'm not entirely sure I understand the
    breaking out of the send and recieve loop when 'recv' is set
    - seems to me that would ensure one request/reply is read,
    not all possible as is implied by the comments. But hey, it
    seems to work again and it's a great little library :)

     
  • Mike Grant
    Mike Grant
    2006-06-08

    Logged In: YES
    user_id=1175208

    Applied patch to CVS, hopefully fixed.

     
  • Mike Grant
    Mike Grant
    2006-07-19

    • status: open --> closed-fixed