本文整理汇总了Python中threading.Thread.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.stop方法的具体用法?Python Thread.stop怎么用?Python Thread.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.Thread
的用法示例。
在下文中一共展示了Thread.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
class Receiver:
def __init__(self, ipAddr='127.0.0.1', port = 9001) :
self.ipAddr = ipAddr
self.port = port
self.addr = (ipAddr, port)
if LIBLO:
self.t = liblo.ServerThread(port)
else:
self.osc = OSC.ThreadingOSCServer(self.addr)
self.t = Thread(target=self.osc.serve_forever)
self.t.start()
def init(self): pass
def listen(self): self.init()
def quit(self):
if LIBLO: self.t.stop()
else: self.osc.close()
def add(self, func, addr):
if LIBLO: self.t.add_method(addr,None, lambda *f: func(f[1]))
else: self.osc.addMsgHandler(addr, lambda *f: func(f[2]))
def bind(self, addr,func): self.add(func, addr)
def unbind(self, addr):
if LIBLO: pass
else: self.osc.delMsgHandler(addr)
def remove(self, addr): self.unbind(addr)
示例2: main
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
def main():
parser = argparse.ArgumentParser()
parser.add_argument("interface", type=str, help="the network interface",
choices=interfaces(),
)
parser.add_argument("user", type=str, default=os.environ['USER'],
nargs='?',
help="Your username",
)
args = parser.parse_args()
inet = ifaddresses(args.interface)[AF_INET]
addr = inet[0]['addr']
masked = addr.rsplit('.', 1)[0]
ctx = zmq.Context.instance()
listen_thread = Thread(target=listen, args=(masked,))
listen_thread.start()
bcast = ctx.socket(zmq.PUB)
bcast.bind("tcp://%s:9004" % args.interface)
print("starting chat on %s:9004 (%s.*)" % (args.interface, masked))
localnode = LocalNode()
while True:
try:
msg = raw_input()
#IP/tun0/bat0: freqChange rx/tx
message = localnode.name + " freqChange 915000"
bcast.send_string(message)
#bcast.send_string("%s: %s" % (args.user, msg))
except KeyboardInterrupt:
break
bcast.close(linger=0)
ctx.term()
listen_thread.stop()
示例3: emit
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
class webServer:
def emit(self,data):
#print data
for c in cl:
c.write_message(data)
def runWebServer(self,cntrl,wms):
ApiHandler.controller = cntrl
SocketHandler.controller = cntrl
WMSHandler.wms = wms
app = web.Application([
(r'/ws', SocketHandler),
(r'/api', ApiHandler),
(r'/wms', WMSHandler),
(r'/(.*)', web.StaticFileHandler, {'path': "data/web", "default_filename": "index.html"})
],
debug=True)
app.listen(5566)
self.t = Thread(target=ioloop.IOLoop.instance().start)
self.t.daemon = True
self.t.start()
def stop():
self.t.stop()
示例4: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
class Sceduler:
def __init__(self, config):
fs = config.get('scheduler', 'fs', 0)
dest = config.get('store', 'path', 0)
self.ioqueue = Queue()
self.iothread = Thread(target=self.ioprocess)
self.iothread.daemon = True
self.observer = Observer()
self.event_handler = IoTask(self.ioqueue, fs, dest)
self.observer.schedule(self.event_handler, fs, recursive=True)
def ioprocess(self):
while True:
t = self.ioqueue.get()
try:
t.process()
finally:
self.ioqueue.task_done()
def start(self):
self.observer.start()
self.iothread.start()
def stop(self):
self.observer.stop()
self.iothread.stop()
def join(self):
self.observer.join()
self.iothread.join()
示例5: ClientServerApp
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
class ClientServerApp(App):
def build(self):
self.service = None
# self.start_service()
self.server = server = OSCThreadServer()
server.listen(
address=b'localhost',
port=3002,
default=True,
)
server.bind(b'/message', self.display_message)
server.bind(b'/date', self.date)
self.client = OSCClient(b'localhost', 3000)
self.root = Builder.load_string(KV)
return self.root
def start_service(self):
if platform == 'android':
service = autoclass(SERVICE_NAME)
mActivity = autoclass(u'org.kivy.android.PythonActivity').mActivity
argument = ''
service.start(mActivity, argument)
self.service = service
elif platform in ('linux', 'linux2', 'macos', 'win'):
from runpy import run_path
from threading import Thread
self.service = Thread(
target=run_path,
args=['src/service.py'],
kwargs={'run_name': '__main__'},
daemon=True
)
self.service.start()
else:
raise NotImplementedError(
"service start not implemented on this platform"
)
def stop_service(self):
if self.service:
self.service.stop()
self.service = None
def send(self, *args):
self.client.send_message(b'/ping', [])
def display_message(self, message):
if self.root:
self.root.ids.label.text += '{}\n'.format(message.decode('utf8'))
def date(self, message):
if self.root:
self.root.ids.date.text = message.decode('utf8')
示例6: test_events_with_callback
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
def test_events_with_callback():
"""Test subscribing to events with a callback handler."""
def _callback_handler(message):
"""Event callback handler."""
global CALLBACK_EVENT_COUNT # pylint: disable=global-statement
CALLBACK_EVENT_COUNT += 1
assert 'callback_test_event_' in message['data']
# print('EVENT CALLBACK!! ', message['data'], CALLBACK_EVENT_COUNT)
def _watcher_function(queue: EventQueue, timeout: float):
"""Monitor for events."""
start_time = time.time()
while time.time() - start_time < timeout:
queue.get()
time.sleep(0.1)
DB.flush_db()
object_type = 'callback_test'
subscriber = 'test_subscriber'
event_type = 'test'
object_id = 'test-01'
# Subscribe to the 'pb' object events with the 'test' subscriber
event_queue = subscribe(object_type, subscriber,
_callback_handler)
assert subscriber in get_subscribers(object_type)
# Test using a custom watcher thread for the event loop.
thread = Thread(target=_watcher_function, args=(event_queue, 2.0,),
daemon=False)
thread.start()
for _ in range(10):
publish(event_type=event_type, object_type=object_type,
object_id=object_id)
thread.join()
assert CALLBACK_EVENT_COUNT == 10
# Test using the provided pubsub subscriber thread
thread = event_queue.pubsub().run_in_thread(sleep_time=0.01)
for _ in range(10):
publish(event_type=event_type, object_type=object_type,
object_id=object_id)
time.sleep(0.5)
thread.stop()
assert CALLBACK_EVENT_COUNT == 20
示例7: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
class Receiver:
def __init__(self, ipAddr='127.0.0.1', port = 9001) :
self.ipAddr = ipAddr
self.port = port
self.addr = (ipAddr, port)
self.tags = set()
if LIBLO:
#self.t = liblo.ServerThread(port, proto=liblo.TCP)
self.t = liblo.ServerThread(port, proto=liblo.UDP)
else:
self.osc = OSC.ThreadingOSCServer(self.addr)
self.t = Thread(target=self.osc.serve_forever)
self.t.start()
def init(self): pass
def listen(self): self.init()
def close(self):
self.quit()
def quit(self):
if LIBLO: self.t.stop(); self.t.free(); gc.collect()
else: self.osc.running = False; self.t.join(); self.osc.close();
def add(self, func, tag):
if tag in self.tags: return
if LIBLO: self.t.add_method(tag,None, lambda *f: func(f[1]))
else: self.osc.addMsgHandler(tag, lambda *f: func(f[2]))
self.tags.add(tag)
def bind(self, tag,func): self.add(func, tag)
def unbind(self, tag):
if tag not in self.tags: return
if LIBLO: pass # self.t.del_method(tag, None)
else: self.osc.delMsgHandler(tag)
self.tags.remove(tag)
def remove(self, tag): self.unbind(tag)
def unbind_all(self):
for tag in list(self.tags): self.unbind(tag)
示例8: ResourceMonitor
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
class ResourceMonitor(object):
# Start monitoring all resources.
def __init__ (self,duration,numsamples):
self.duration = duration
self.numsamples = numsamples
self.cpuarray = []
self.iorkbpsarray = []
self.iowkbpsarray = []
def Start(self):
self.t = Thread(target=self.myfunc, args=(self.duration,self.numsamples))
self.t.start()
# Stop monitoring all resources.
def Stop(self):
self.t.stop()
def myfunc (self,duration,numsamples):
while 1:
self.cpuarray.append (self.GetIndividualStatisticCPU ());
if (len (self.cpuarray) > numsamples):
self.cpuarray.pop(0)
self.iorkbpsarray.append (self.GetIndividualStatisticIORKBPS ());
if (len (self.iorkbpsarray) > numsamples):
self.iorkbpsarray.pop(0)
self.iowkbpsarray.append (self.GetIndividualStatisticIOWKBPS ());
if (len (self.iowkbpsarray) > numsamples):
self.iowkbpsarray.pop(0)
print "Start sleeping for ",duration
#time.sleep (duration)
threading.Event().wait(duration)
print "Stop sleeping"
# Get the latest value (moving average) for the statistic 'stat_name'.
def GetIndividualStatisticCPU(self):
p = os.popen("iostat")
i=0;
while 1:
line = p.readline()
if not line: break
if (i==3):
tmparray = [float(x) for x in line.split()]
f = float (tmparray[0])
return f
i += 1
print line
def GetIndividualStatisticIORKBPS(self):
p = os.popen("iostat -d -x -h -k sda")
i=0;
while 1:
line = p.readline()
if not line: break
if (i==3):
tmparray = [x for x in line.split()]
f = float (tmparray[5])
return f
i += 1
print line
def GetIndividualStatisticIOWKBPS(self):
p = os.popen("iostat -d -x -h -k sda")
i=0;
while 1:
line = p.readline()
if not line: break
if (i==3):
tmparray = [x for x in line.split()]
f = float (tmparray[6])
return f
i += 1
print line
def GetStatistic (self,stat_name):
if (stat_name is "cpu"):
array = self.cpuarray;
elif (stat_name == "io-rkbps"):
array = self.iorkbpsarray;
elif (stat_name == "io-wkbps"):
array = self.iowkbpsarray
else:
print "Big problem. No such statistic",stat_name
return -1
sumarray = sum (array)
numsamples = len (array)
avg = sumarray / float (numsamples)
return avg
示例9: ClassroomDiscover
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
class ClassroomDiscover(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
# avahi initialization
self._service = None
toolbar_box = ToolbarBox()
self._vbox = Gtk.VBox()
activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(activity_button, 0)
activity_button.show()
# get information from gconf
client = GConf.Client.get_default()
self._age = client.get_int('/desktop/sugar/user/age')
self._gender = client.get_string('/desktop/sugar/user/gender')
if self._gender is None:
self._gender = 'male'
teacher = (self._age >= 25)
# if age is not configured age == 0
if teacher or self._age == 0:
teacher_button = ToggleToolButton('%s-7' % self._gender)
teacher_button.set_tooltip(_('Teacher'))
teacher_button.show()
teacher_button.connect('toggled', self.__start_teacher_cb)
toolbar_box.toolbar.insert(teacher_button, -1)
if teacher:
teacher_button.set_active(True)
if not teacher or self._age == 0:
student_button = ToggleToolButton('%s-2' % self._gender)
student_button.set_tooltip(_('Student'))
student_button.show()
student_button.connect('toggled', self.__start_student_cb)
toolbar_box.toolbar.insert(student_button, -1)
if self._age > 0:
# is a student
student_button.set_active(True)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
separator.show()
toolbar_box.toolbar.insert(separator, -1)
stopbutton = StopButton(self)
toolbar_box.toolbar.insert(stopbutton, -1)
stopbutton.show()
self.set_toolbar_box(toolbar_box)
toolbar_box.show()
self.scrolled = Gtk.ScrolledWindow()
self.scrolled.add_with_viewport(self._vbox)
self.scrolled.show_all()
self.set_canvas(self.scrolled)
self._inhibit_suspend()
def _joined_cb(self, also_self):
"""Callback for when a shared activity is joined.
Get the shared tube from another participant.
"""
self.watch_for_tubes()
GObject.idle_add(self._get_view_information)
def _show_received_student_info(self, student_data):
logging.error('received data %s', student_data)
hbox = Gtk.HBox()
label_n = Gtk.Label()
label_n.set_text('Name: %s' % student_data['nick_name'][0])
hbox.add(label_n)
label_a = Gtk.Label()
label_a.set_text('Age: %s' % student_data['age'][0])
hbox.add(label_a)
label_g = Gtk.Label()
label_g.set_text('Gender: %s' % student_data['gender'][0])
hbox.add(label_g)
hbox.show_all()
self._vbox.pack_start(hbox, False, False, 10)
logging.error('added to the canvas')
def __start_teacher_cb(self, button=None):
if self._service is None:
# get a free port
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
sock.bind(('', 0))
#.........这里部分代码省略.........
示例10: keyDown
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
## KEYBINDINGS
def keyDown(event):
serialQueue.put(event.char)
def keyRelease(event):
serialQueue.put(event.char.upper())
os.system('xset r off') #stop X repeat multiple key presses
root.bind("<KeyPress>", keyDown)
root.bind("<KeyRelease>", keyRelease)
## Start Worker threads
serialWorker = Thread(target=serialWorkerFunction, args=(serialQueue,))
serialWorker.setDaemon(True)
serialWorker.start()
statWorker = Thread(target=pollForStats)
statWorker.start()
# Hand main thread over to the Tkinter event loop
root.mainloop()
os.system('xset r on')
# Close open handles on exit
logFile.close()
serial.close()
serialWorker.stop()
statWorker.stop()
示例11: updateMeasure
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
ax.set_zlim(0, 400)
plt.show()
def updateMeasure(n):
while True:
retval = pic.get_dist()
measurement.set((retval[0] - 53) / 14.7)
time.sleep(1)
pan_slider = Scale(root, orient=HORIZONTAL, from_=0, to=d_range, label='Pan Angle', variable = pan, command = move_servo)
pan_slider.pack(anchor=CENTER)
tilt_slider = Scale(root, orient=HORIZONTAL, from_=0, to=d_range, label='Tilt Angle', variable = tilt, command = move_servo)
tilt_slider.pack(anchor=CENTER)
measurement = StringVar()
measure_lbl = Label(root, textvariable=measurement)
measure_lbl.pack(anchor=CENTER)
btn_auto = Button(root, anchor=CENTER, text='Auto-measurement', command=getPixelCloud)
btn_auto.pack(anchor=CENTER)
t = Thread(target=updateMeasure, args=(.01,))
t.start()
root.mainloop()
t.stop()
示例12: simpleFrame
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
class simpleFrame(wx.Frame):
def __init__(self,parent,ID,title):
wx.Frame.__init__(self, parent,ID,title, size=wx.Size(300,200) )
self.ser = serial.Serial(C_serial, C_serial_speed)
self.EnableCloseButton(False)
self.timeleft = 0
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.m_statusBar1 = self.CreateStatusBar( 1, wx.ST_SIZEGRIP, wx.ID_ANY )
self.Bind( serialrx, self.serial)
self.t = Thread(target=self.readSerial)
self.t.start()
self.SetSizer(self.sizer)
self.Layout()
self.Centre( wx.BOTH )
self.timer = wx.Timer(self, 100)
wx.EVT_TIMER(self, 100, self.ontimer)
def ontimer(self,evt):
self.guitime.SetValue( self.timeleft )
self.timeleft = self.timeleft - 1
self.m_statusBar1.SetStatusText("User is: %s Time Left: %d minutes" % (self.userName , self.timeleft/60) )
if self.timeleft < 0:
self.logoutfunc(False)
def logoutfunc(self,evt):
self.timer.Stop()
log("%s stopped using device" % self.userName)
self.ser.write('user:-1')
self.sizer.Clear(True)
self.sizer.AddSpacer( ( 0, 30), 1, wx.EXPAND, 5 )
self.sizer.Add( wx.StaticText( self, wx.ID_ANY, u"Scan Badge to login" ),wx.ALL|wx.ALIGN_CENTER,5)
self.m_statusBar1.SetStatusText("Scan Badge to login")
self.userName = False
self.Layout()
def serial(self, evt):
global C_code
usercode = evt.attr1
# print("got %s" % usercode)
print( "%s/device/0/code/%s" % ( C_server, usercode) )
code = requests.get( url="%s/device/0/code/%s" % ( C_server, usercode) )
code = int(code.text)
C_code = code
self.m_statusBar1.SetStatusText("Level is: %s" % levels[code])
# if they have access to the machine
if code > 0:
self.userName = requests.get( url="%s/user/code/%s" % ( C_server, usercode) )
self.userName = str(self.userName.text)
self.ser.write('%s:1' % self.userName)
log("%s started using device" % self.userName)
self.timeleft = C_timeout
self.sizer.Clear(True)
self.logout = wx.Button(self, wx.ID_ANY, u"Logout", wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT)
self.timertext = wx.StaticText( self, wx.ID_ANY, u"Time Left" )
self.guitime = wx.Gauge( self, wx.ID_ANY, C_timeout , wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL)
self.sizer.AddSpacer( ( 0, 30), 1, wx.EXPAND, 5 )
self.sizer.Add(self.timertext, wx.ALL|wx.ALIGN_CENTER,5)
self.sizer.Add(self.guitime, wx.ALL|wx.ALIGN_CENTER,5)
self.sizer.AddSpacer( ( 0, 20), 1, wx.EXPAND, 5 )
self.sizer.Add(self.logout, wx.ALL|wx.ALIGN_CENTER,5)
self.sizer.AddSpacer( ( 0, 20), 1, wx.EXPAND, 5 )
self.guitime.SetValue(self.timeleft)
self.logout.Bind( wx.EVT_BUTTON, self.logoutfunc)
self.Layout()
self.timer.Start(1000)
else:
self.ser.write('user:-1')
def readSerial(self):
while True:
message = self.ser.readline()[2:-4].strip()
evt = s(attr1=message)
wx.PostEvent(self,evt)
time.sleep(5)
def onClose(self,event):
self.t.stop()
示例13: VPNService
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
class VPNService(Container,MultiPointVPNService):
def __init__(self):
Resource.__init__(self,"MultiPointVPNService")
print "MultiPoint VPN Service is starting"
self.vpnIndex = {}
self.vpnIndexById = {}
self.topology = None
self.coretopology = None
self.lock = threading.Lock()
self.properties['mat'] = True # Default.
self.loadService()
self.saveThread = Thread(target=self.autosave)
self.saveThread.start()
if self.topology != None:
self.setscc()
def setscc(self):
self.SCC = SdnControllerClient()
self.sccThread = JavaThread(self.SCC)
self.sccThread.start()
self.VPNcallback = VpnCallback("MP-VPN Service", self)
setcallback(self.VPNcallback)
self.SCC.setCallback(self.VPNcallback)
def settopos(self, popstoponame, coretoponame):
self.properties['topology'] = popstoponame
self.topology = Container.getContainer(self.properties['topology'])
self.properties['coretopology'] = coretoponame
self.coretopology = Container.getContainer(self.properties['coretopology'])
# We can now set up the callback
self.setscc()
self.saveService()
def shutdown(self):
self.saveThread.stop()
if self.sccThread != None:
self.sccThread.stop()
self.SCC.clearCallback()
MultiPointVPNServiceFactory.delete()
def autosave(self):
while True:
if not self.topology == None:
self.saveService()
for (x,vpn) in self.vpnIndex.items():
vpn.saveVPN()
time.sleep(60)
def saveService(self):
self.properties['sid'] = self.sid
if self.topology != None:
self.properties['topology'] = self.topology.getResourceName()
if self.coretopology != None:
self.properties['coretopology'] = self.coretopology.getResourceName()
try:
self.save()
except:
print "Failed to save VPN Service\n", sys.exc_info()[0]
def loadService(self):
stored = Container.getContainer(self.getResourceName())
mapResource (obj=self,resource=stored)
if 'topology' in self.properties:
self.topology = Container.getContainer(self.properties['topology'])
if 'coretopology' in self.properties:
self.coretopology = Container.getContainer(self.properties['coretopology'])
vpns = self.loadResources({"resourceType":"VPN"})
for v in vpns:
vpn = VPN(v.getResourceName())
vpn.loadVPN(self)
self.vpnIndex[v.getResourceName()] = vpn
self.vpnIndexById[vpn.vid] = vpn
if not 'mat' in self.properties:
self.properties['mat'] = True
def newVid(self):
with self.lock:
while True:
v = random.randint(1,65535)
if not v in self.vpnIndexById:
return v
def getSite(self,s):
global sites
if s in sites:
return sites[s]
else:
return None
def getHost(self,s):
return tbns[s]
def addVpn(self,vpn):
self.vpnIndex[vpn.name] = vpn
self.vpnIndexById[vpn.vid] = vpn
self.saveResource(vpn)
def createVPN(self,vpnname):
if vpnname in self.vpnIndex:
return None
#.........这里部分代码省略.........
示例14: quit
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
def quit(self):
Thread.stop()
sys.exit(app.exec_())
示例15: TcpClientConnection
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import stop [as 别名]
class TcpClientConnection(ModemConnection):
def __init__(self, modem, remote_host, remote_port, local_host=None, local_port=None, timeout=0.1):
self._incoming_line_buffer = ""
self.connection_type = "udp"
self.modem = modem
self.timeout = timeout
self._remote_host = remote_host
self._remote_port = remote_port
if local_host is None:
self._local_host = ""
else:
self._local_host = local_host
if local_port is None:
self._local_port = remote_port
else:
self._local_port = local_port
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._socket.connect((self._remote_host, self._remote_port))
self._thread = Thread(target=self._listen)
self._thread.setDaemon(True)
self._thread.start()
@property
def is_connected(self):
return True
@property
def can_change_baudrate(self):
return False
def change_baudrate(self,baudrate):
return None
def close(self):
self._thread.stop()
self._socket.close()
def _listen(self):
while True:
msg_lines = self.readlines()
# We are connected, so pass through to NMEA
if msg_lines is not None:
for line in msg_lines:
self.modem._process_incoming_nmea(line)
self.modem._process_outgoing_nmea()
def readlines(self):
"""Returns a \n terminated line from the modem. Only returns complete lines (or None on timeout)"""
rl = self._socket.recv(1024)
if rl == "":
return None
self._incoming_line_buffer += rl
# Make sure we got a complete line. Serial.readline may return data on timeout.
if '\n' in self._incoming_line_buffer:
# is there a newline at the end?
lines = self._incoming_line_buffer.splitlines(True)
# See if the last line has a newline at the end.
if lines[-1][-1] != '\n':
self._incoming_line_buffer = lines[-1]
lines.pop() # remove it from the list to passed on
# return the list of complete lines
return lines
else:
return None
def write(self, data):
self._socket.send(data)