[Pythonmac-SIG] macostools.copy failing after volumes are mounted or unmounted during script execution

Paul C. Pharr pharr at nemetschek.net
Thu Jun 3 13:56:17 EDT 2004


Hi everyeone,

I have attempted to use the macostools.copy call under python 2.3 (stock install under Panther) to copy a large quantity
of files to a file server from a python script which runs continuously as a server process. After recently changing the
script to dynamically mount the server volumes as necessary using the command line "mount" command, I started getting
seemingly random, but frequent failures referencing a -120 Directory Not Found error. After investigation, it turned out
that this failure always happened on the third copy operation to a new directory.

Thinking I had found a subtle MacOS X bug, I submitted a request to Apple's Developer Technical Support, and after a few
days got a long and informative response which said essentially that:

The Carbon File Manager, opon which macostools is based, depends on being notified within the process's runloop when
volumes are mounted or unmounted within the file system. When I make a system call from my script to mount or unmount a
volume, my script and its instance of the Carbon File Manager is not notified because it does not have a runloop.


My question to you Mac Python experts out there is this:

I have seen some references to Mac python scripts implementing a runloop to respond to system needs. Is there a
standard, simple (hopefully trivial) way to do this which would allow Carbon File Manager to get the notification it
needs? Is there a complicated way to accomplish this?


Alternately, does anyone know of smething I can do within my script after mounting or unmounting a volume from within my
script which will give CFM a kick so it will requery the state of all mounted volumes and eliminate the need to respond
to these notifications?

Many thanks in advance,


Paul Pharr




More information about the Pythonmac-SIG mailing list