On Dec 17, 2011, at 11:36 AM, Amaury Forgeot d'Arc wrote:

> 2011/12/17 Scott Leerssen <sleers...@gmail.com>
> Closing the PyHANDLE leaves the file object with an invalid descriptor, and 
> closing the file object leaves the PyHANDLE with an invalid descriptor, but 
> only sometimes
> 
> After open_osfhandle(), the handle is owned by the file object, and should 
> not be closed when the PyHANDLE object is deallocated.
> Did you try to use the Detach() method? Something like
>    fd = open_osfhandle(h.Detach(), os.O_RDONLY)
> Documentation says: "You would call this function when you need the 
> underlying win32 handle to exist beyond the lifetime of the handle object" 
> which seems adequate here.

I did see that, but I interpreted that to mean that the PyHANDLE would be 
dereferenced from the underlying Windows file handle, and I'm not sure what the 
consequences of that would be.  That is, how would I free that resource if I 
lose it from the Python context?  Also, it didn't seem to fit since I didn't 
want a win32 handle to live past the close.  I just wanted all the associated 
handles and descriptors to close at the same time.

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to