Commit 0c412496 by Bach Dániel

handle disconnect

parent 6be953f1
......@@ -57,6 +57,9 @@ class SerialLineReceiver(SerialLineReceiverBase):
return d
reactor.addSystemEventTrigger("before", "shutdown", shutdown)
def connectionLost(self, reason):
reactor.stop()
def connectionLost2(self, reason):
self.send_command(command='agent_stopped',
args={})
......
......@@ -7,7 +7,9 @@ Virtio-Serial Port Protocol
"""
# system imports
import logging
import os
from time import sleep
# dependent on pyserial ( http://pyserial.sf.net/ )
# only tested w/ 1.18 (5 Dec 2002)
......@@ -15,6 +17,8 @@ import os
# twisted imports
from twisted.internet import abstract, fdesc
logger = logging.getLogger()
class SerialPort(abstract.FileDescriptor):
"""
......@@ -57,4 +61,8 @@ class SerialPort(abstract.FileDescriptor):
"""
abstract.FileDescriptor.connectionLost(self, reason)
os.close(self._serial)
self.protocol.connectionLost(reason)
sleep(2)
self._serial = os.open(
self.port, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
self.startReading()
logger.info("Reconnecting")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment