Timeout on file write?

Chris Farley nbrewer at visi.com
Sat Jun 26 12:28:22 EDT 2004


I'm working on a cross-platform Python program that prints to a receipt 
printer.  The code is simple, I just do something like this:

printer = file('/dev/lp0','w')          # on Win32, change to 'lpt1'
p.write("whatever")
p.close()


I would like to gracefully handle situations such as when the paper is out 
or the printer is powered off. Right now the program just hangs.

Suggestions? Thanks...



More information about the Python-list mailing list