It is not totally obvious how TEX processes are supervised by PyX and why it's done that way. However there are good reasons for it and the following description is intended for people wanting and/or needing to understand how temporary files are used by PyX. All others don't need to care.
Each time PyX needs to start a new TEX process, it creates a
base file name for temporary files associated with this process. This
file name is used as \jobname by TEX. Since TEX does not
handle directory names as part of \jobname, the temporary files
will be created in the current directory. The PyX developers
decided to not change the current directory at all, avoiding all kind
of issues with accessing files in the local directory, like for
loading graph data, LATEX style files etc.
PyX creates a TEX file containing \relax only. It's only
use is to set TEXs \jobname. Immediately after processing
\relax TEX falls back to stdin to read more commands. PyX
than uses stdin and stdout to avoid various buffering
issues which would occur when using files (or named pipes). By that
PyX can fetch TEX errors as soon as they occur while keeping the
TEX process running (i.e. in a waiting state) for further input.
The size of the TEX output is also availble immediately without
fetching the dvi file created by TEX, since PyX uses some
TEX macros to output the extents of the boxes created for the
requested texts to stdout immediately. There is a TeX hack
--ipc which PyX knows to take advantage of to fetch
informations from the dvi file immediately as well, but it's
not available on all TEXinstallations. Thus this feature is disabled
by default and fetching informations from the dvi is tried to
be limited to those cases, where no other option exists. By that
TEX usually doesn't need to be started several times.
By default PyX will clean up all temporary files after TEX was
stopped. However the usefiles list allows for a renaming of the
files from (and to, if existing) the temporary \jobname (+
suffix) handled by PyX. Additionally, since PyX does not write a
useful TEX input file in a file and thus a
usefiles=["example.tex"] would not contain the code actually
passed to TEX, the texdebug feature of the texrunner can be
used instead to get a the full input passed to TEX.
In case you need to control the position where the temporary files are
created (say, you're working on a read-only directory), the suggested
solution is to switch the current directory before starting with text
processing in PyX (i.e. an os.chdir at the beginning of your
script will do fine). You than just need to take care of specifying
full paths when accessing data from your original working directory,
but that's intended and necessary for that case.