Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kliment/Printrun.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2013-06-04 17:18:25 +0400
committerGuillaume Seguin <guillaume@segu.in>2013-06-04 17:18:25 +0400
commit47d25b92044ff35bbc5e510f5d7dde25cb3040ac (patch)
treed43ff89540abd1d5964f44517768bb857ae4314a /printcore.py
parent93d258f655ee5d5321bddbdfe66bbdcf6063d255 (diff)
Use a Queue for priqueue instead of a pure list
Diffstat (limited to 'printcore.py')
-rwxr-xr-xprintcore.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/printcore.py b/printcore.py
index 5eecb43..6eefa52 100755
--- a/printcore.py
+++ b/printcore.py
@@ -18,6 +18,7 @@
from serial import Serial, SerialException
from select import error as SelectError
from threading import Thread, Lock
+from Queue import Queue
import time, getopt, sys
import platform, os, traceback
import socket
@@ -61,7 +62,7 @@ class printcore():
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.mainqueue = None
- self.priqueue = []
+ self.priqueue = Queue(0)
self.queueindex = 0
self.lineno = 0
self.resendfrom = -1
@@ -382,7 +383,7 @@ class printcore():
"""
if self.online:
if self.printing:
- self.priqueue.append(command)
+ self.priqueue.put_nowait(command)
else:
while self.printer and self.printing and not self.clear:
time.sleep(0.001)
@@ -439,8 +440,9 @@ class printcore():
self.resendfrom += 1
return
self.resendfrom = -1
- if self.priqueue:
- self._send(self.priqueue.pop(0))
+ if not self.priqueue.empty():
+ self._send(self.priqueue.get_nowait())
+ self.priqueue.task_done()
return
if self.printing and self.queueindex < len(self.mainqueue):
(layer, line) = self.mainqueue.idxs(self.queueindex)