[Xcb] xpyb and threading
Josh Triplett
josh at joshtriplett.org
Thu Feb 25 14:43:50 PST 2010
On Tue, Feb 23, 2010 at 11:36:41PM -0800, Jamey Sharp wrote:
> On Tue, Feb 23, 2010 at 6:14 PM, Eamon Walsh
> <ewalsh.mailinglists at gmail.com> wrote:
> > Josh Triplett wrote:
> >> For that matter, can another thread
> >> call xcb_disconnect on self->conn before you call xcb_wait_for_event?
> >
> > It looks like it is possible for this to race with xcb_disconnect() if
> > another thread calls the "disconnect" method explicitly.
>
> Naturally, this is a problem in pure C programs as well. I've always
> figured it was a case of "yes, but don't do that." It's the
> responsibility of the component that created the connection to ensure
> that nothing is using it before destroying it.
Agreed.
> >> here, you use self->conn, but can another thread make self go
> >> away before you dereference it?
>
> I believe I know less about Python internals than Josh does, but this
> seems to me like the key issue--and an easily fixed one.
*nod*
> > An alternative would be to remove the disconnect method from xpyb
> > or turn it into a no-op, but that would make it impossible to close the
> > connection immediately (it would happen at garbage collection time).
>
> In a garbage-collected language, that is certainly an interesting alternative.
Interesting indeed. As long as you could ensure that all references to
the object go away when you want the connection closed, it might work
out, though you usually have no guarantee of timely GC.
- Josh Triplett
More information about the Xcb
mailing list