Commit 47d25b92 authored by Guillaume Seguin's avatar Guillaume Seguin

Use a Queue for priqueue instead of a pure list

parent 93d258f6
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
from serial import Serial, SerialException from serial import Serial, SerialException
from select import error as SelectError from select import error as SelectError
from threading import Thread, Lock from threading import Thread, Lock
from Queue import Queue
import time, getopt, sys import time, getopt, sys
import platform, os, traceback import platform, os, traceback
import socket import socket
...@@ -61,7 +62,7 @@ class printcore(): ...@@ -61,7 +62,7 @@ class printcore():
self.online = False #The printer has responded to the initial command and is active self.online = False #The printer has responded to the initial command and is active
self.printing = False #is a print currently running, true if printing, false if paused self.printing = False #is a print currently running, true if printing, false if paused
self.mainqueue = None self.mainqueue = None
self.priqueue = [] self.priqueue = Queue(0)
self.queueindex = 0 self.queueindex = 0
self.lineno = 0 self.lineno = 0
self.resendfrom = -1 self.resendfrom = -1
...@@ -382,7 +383,7 @@ class printcore(): ...@@ -382,7 +383,7 @@ class printcore():
""" """
if self.online: if self.online:
if self.printing: if self.printing:
self.priqueue.append(command) self.priqueue.put_nowait(command)
else: else:
while self.printer and self.printing and not self.clear: while self.printer and self.printing and not self.clear:
time.sleep(0.001) time.sleep(0.001)
...@@ -439,8 +440,9 @@ class printcore(): ...@@ -439,8 +440,9 @@ class printcore():
self.resendfrom += 1 self.resendfrom += 1
return return
self.resendfrom = -1 self.resendfrom = -1
if self.priqueue: if not self.priqueue.empty():
self._send(self.priqueue.pop(0)) self._send(self.priqueue.get_nowait())
self.priqueue.task_done()
return return
if self.printing and self.queueindex < len(self.mainqueue): if self.printing and self.queueindex < len(self.mainqueue):
(layer, line) = self.mainqueue.idxs(self.queueindex) (layer, line) = self.mainqueue.idxs(self.queueindex)
......
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