Thursday, 15 March 2012

python - Calling twisted's win32eventreactor.Win32Reactor() method "stop" doesn't stop reactor -



python - Calling twisted's win32eventreactor.Win32Reactor() method "stop" doesn't stop reactor -

in serial communications i'm using twisted's reactor=win32eventreactor.win32reactor(). transport using serial port.

reactor running in other thread (it's serial communication thread running in help of reactor)

before calling reactor.run() i'm creating serialport this:

try: serialport(protocol(self.reactor, self), self.cfg.comport, self.reactor, baudrate=self.cfg.baudrate, bytesize=bytesize, parity=parity, stopbits=stopbits_one, xonxoff=0, rtscts=0) self.connected = true except serial.serialexception, ex: self.log.error('serial exception: {0}'.format(ex)) self.connected = false except valueerror, ex: self.log.error('serial exception: {0}'.format(ex)) self.connected = false finally: self.comm_event.set()

on creation occurs error. example: serial exception: not open port 'com9': windowserror(2, 'the scheme cannot find file specified.')

and okay, should error. error protocol instance not have transport (in case of success - have).

after i'm calling reactor.run(). it's okay, because main thread manage communication thread , phone call reactor.stop() in case of error (mentioned before). if error occurs before calling reactor.run() , after calling reactor.stop() (calling mainthread) doesn't stop reactors main loop. in case no error occurs before calling reactor.run(), reactor.stop() calling procedure stops reactor.

it looks reactor ignoring reactor.stop() if there error on transport creation.

so maybe have , thought why? or maybe how debug reactor.stop() procedure find why reactor not stopping?

python multithreading twisted reactor

No comments:

Post a Comment