Massimo Di Stefano wrote:

> the work-around :
> 
> > while 1:
> >   try:
> >       function() 
> >       break
> >   except IOError: 
> >       sleep(0.1)
> 
> works, 
> but i have to add it for each grass command i'm running in the code.

First, I'd suggest checking to see whether this has been fixed in a
later version of Python. Or that the Python developers are at least
aware of it. Are you using the version from python.org?

If you can't get a correctly-functioning version of Python, I'd
suggest using a wrapper rather than writing the loop out repeatedly,
e.g.:

        def fixed(func, *args, **kwargs):
            while True:
                try:
                    return func(*args, **kwargs)
                except IOError:
                    pass

        def fix(func):
            def f(*args, **kwargs):
                return fixed(func, *args, **kwargs)
            return f

Then you can use e.g.:

        read = fix(read)

to create a fixed version of the function. Similarly for methods:

        MyType.my_method = fix(MyType.my_method)

Or you can wrap individual calls, replacing "func(...)" with
"fixed(func, ...)".

-- 
Glynn Clements <[email protected]>
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to