Timeout on file write?

Chris Farley nbrewer at visi.com
Sat Jun 26 21:57:29 CEST 2004


Larry Bates <lbates at swamisoft.com> wrote:

> second option, you could try something like:
> p.write("whatever")
> try:
>     p.write("whatever")
>     p.flush()

> except:
>       print "Write error on receipt printer"

> p.close()

This doesn't work, as the call to flush just hangs if the printer is
powered down. It does not throw an exception. 

Would it work to start a new thread, and if the thread doesn't return
in a specified time, destroy it? I've read that Python thread's can not
be interrupted, so I'm a bit skeptical that this would work...




More information about the Python-list mailing list