Commit 16208aec authored by Guillaume Seguin's avatar Guillaume Seguin

Use a fixed-size deque for storing the log

deque is much better fitted than a simple Python list
Indeed, a standard Python list is stored as an array, and has to be reallocated
all the time, while a deque has very fast operation on both ends, and the fixed
size mode will automatically drop first element when pushing to a full deque.
Also it was crazy to store the whole log. Storing 10000 log lines seems decent
and shouldn't take way too much space (less than 512KB based on a quick
estimation).
This might fix #292 and #353.
parent 3fe969e5
......@@ -20,6 +20,7 @@ from threading import Thread
from select import error as SelectError
import time, getopt, sys
import platform, os
from collections import deque
from GCodeAnalyzer import GCodeAnalyzer
def control_ttyhup(port, disable_hup):
......@@ -54,7 +55,7 @@ class printcore():
self.resendfrom = -1
self.paused = False
self.sentlines = {}
self.log = []
self.log = deque(maxlen = 10000)
self.sent = []
self.tempcb = None #impl (wholeline)
self.recvcb = None #impl (wholeline)
......@@ -342,7 +343,7 @@ class printcore():
while self.printing and self.printer and self.online:
self._sendnext()
self.sentlines = {}
self.log = []
self.log.clear()
self.sent = []
try:
self.print_thread.join()
......
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 to comment