Finding count of currently open file descriptors.

Michael Hudson mwh at python.net
Tue Jul 30 11:11:07 EDT 2002


Tim McNerney <mumbly at oneofus.org> writes:

> Martin v. Löwis wrote:
> > In a Python debug build, you can find out all file objects, but there
> > may be file descriptors not controlled by Python file objects (e.g. if
> > opened by os.open).
> 
> This is more what I'm looking for -- some generic method which is
> within Python itself. How would I go about doing this within the debug
> build?

In 2.2:

sys.getobjects(0, file)

The first arg is a limit on how many objects to return, 0 being no
limit.  The second arg is the type of object to return.

In 2.1 I guess it's something like 

sys.getobjects(0, types.FileType)

Cheers,
M.

-- 
  ... Windows proponents tell you that it will solve things that
  your Unix system people keep telling you are hard.  The Unix 
  people are right: they are hard, and Windows does not solve 
  them, ...                            -- Tim Bradshaw, comp.lang.lisp



More information about the Python-list mailing list