Ticket #4249 defect new
Serialport connection lost not handled.
| Reported by: | mdamen | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | core | Keywords: | |
| Cc: | jason.heeris@… | Branch: | |
| Author: | itamar | Launchpad Bug: |
Description
When you disconnect a device connected to the serial port, twisted reports an unhandled error. Here is the traceback:
Traceback (most recent call last):
File "C:\Python26\Lib\site-packages\twisted\python\log.py", line 84, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "C:\Python26\Lib\site-packages\twisted\python\log.py", line 69, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "C:\Python26\Lib\site-packages\twisted\python\context.py", line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "C:\Python26\Lib\site-packages\twisted\python\context.py", line 37, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File "C:\Python26\Lib\site-packages\twisted\internet\win32eventreactor.py", line 211, in _runAction
closed = getattr(fd, action)()
File "C:\Python26\Lib\site-packages\twisted\internet\_win32serialport.py", line 68, in serialReadEvent
n = win32file.GetOverlappedResult(self._serial.hComPort, self._overlappedRead, 0)
pywintypes.error: (995, 'GetOverlappedResult', 'The I/O operation has been aborted because of either a thread exit or an application request.')
There should be some kind of error handling to prevent this, I had a look at it but can't figure out what should be done. Here's a basic example to reproduce the problem:
from twisted.internet import protocol
from twisted.internet.serialport import SerialPort
from sys import platform
if platform == 'win32':
from twisted.internet import win32eventreactor
win32eventreactor.install()
from twisted.internet import reactor
class TestProto(protocol.Protocol):
def connectionMade(self):
print "connection made"
def connectionLost(self):
print "connection lost"
SerialPort(TestProto(),2, reactor, '115200')
reactor.run()
Change History
Note: See
TracTickets for help on using
tickets.
