Making termios.tcdrain() work with threads?

Grant Edwards grante at visi.com
Tue Nov 26 19:22:49 EST 2002


In article <as0vjp$8c2$1 at nntp6.u.washington.edu>, Donn Cave wrote:

>|        if (s == -1)
>|            return PyErr_SetFromErrno(TermiosError);
[...]
>| But, before I submit a patch, I've noticed that TermiosError is
>| a single, static object (file scope):
>|
>|     static PyObject *TermiosError;
>|
>| Is this going to cause problems if multiple threads have to
>| return errors from the termios methods?
> 
> Don't think so!
> 
> PyEND_ALLOW_THREADS waits for the interpreter lock, so there's
> only one thread at a time past that point.  PyErr_SetFromErrno
> should tuck that data into the thread specific state before
> control gets to the ceval loop where another thread could take
> over.  And I wouldn't think you'd be modifying TermiosError
> anyway.

I wasn't sure what PyErr_SetFromErrno was doing.  I was
concerned that it might be modifying and returning the
TermiosError object somehow.

> As long as 's' is automatic (stack/register) storage, you're
> fine.

It is.

-- 
Grant Edwards                   grante             Yow!  .. I see TOILET
                                  at               SEATS...
                               visi.com            



More information about the Python-list mailing list