serial and threads

Silke natunika at gmx.de
Tue Aug 17 06:15:04 EDT 2004


Hi all!

I'm trying to write a program in python using the modules
'serialwin32' and 'thread' to create one thread that writes to a
serial port and another one that reads from it at 'the same time'. My
definitions are

def NetworkToSerial(input):
        s.write(binascii.unhexlify(input))        
        print "SENT: %s" % input                  

def SerialToNetwork():
                result = s.read(1)
                print "RECEIVED:"
                print binascii.hexlify(result) 

and I call them with

thread.start_new_thread(NetworkToSerial, (command,))             
thread.start_new_thread(SerialToNetwork, ())

The first one seems to run fine, but for the second one I get the
error message 'ClearCommError', 'the handle is invalid'.

Does anyone have a clue whether maybe serialwin32 is not
thread-compatible?

Thanks for your help in advance!

Silke



More information about the Python-list mailing list