[Python-Dev] Internal counter to debug leaking file descriptors

Giampaolo Rodolà g.rodola at gmail.com
Fri Sep 3 20:10:19 CEST 2010


The Windows part slipped under my radar. =)
Unfortunately the Windows binaries still refer to the current version
which doesn't include open files and open connections functionalities.
To have those he'll have to get the latest code from svn and compile
it with mingw32.


--- Giampaolo
http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/

2010/9/3 Terry Reedy <tjreedy at udel.edu>:
> On 9/3/2010 6:09 AM, Giampaolo Rodolà wrote:
>>>
>>> Of course it would be nice to get access to FD stack so that a
>>> full filename can also be retrieved in this case.
>>
>> On Linux, this can be easily achieved by using /proc.
>> You can take a look at how this is done in the current development
>> version of psutil:
>>
>> http://code.google.com/p/psutil/source/browse/trunk/psutil/_pslinux.py?spec=svn633&r=630#266
>> Usage:
>>
>>>>> import psutil, os
>>>>> this_process = psutil.Process(os.getpid())
>>>>> f = open('file.ext', 'w')
>>>>> this_process.get_open_files()
>>
>> ['/home/giampaolo/svn/psutil/file.ext']
>>
>> Same for sockets, a bunch of lines later:
>>
>> http://code.google.com/p/psutil/source/browse/trunk/psutil/_pslinux.py?spec=svn633&r=630#284
>>
>>>>> import socket
>>>>> s = socket.create_connection(('google.com', 80))
>>>>> this_process.get_connections()
>>
>> [connection(family=2, type=1, local_address=('192.168.1.43', 38067),
>> remote_address=('72.14.234.104', 80), status='ESTABLISHED')]
>
> If you can use psutil itself, it has compiled Windows versions for 2.7 and
> 3.1
> https://code.google.com/p/psutil/
>
> --
> Terry Jan Reedy
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/g.rodola%40gmail.com
>


More information about the Python-Dev mailing list