Commit 80e313dc authored by Guillaume Seguin's avatar Guillaume Seguin

Lock connect() int printcore (harden against #153)

parent ffec0fa3
......@@ -17,15 +17,24 @@
from serial import Serial, SerialException
from select import error as SelectError
from threading import Thread
from threading import Thread, Lock
import time, getopt, sys
import platform, os, traceback
import socket
import re
from functools import wraps
from collections import deque
from printrun.GCodeAnalyzer import GCodeAnalyzer
from printrun import gcoder
def locked(f):
@wraps(f)
def inner(*args, **kw):
with inner.lock:
return f(*args, **kw)
inner.lock = Lock()
return inner
def control_ttyhup(port, disable_hup):
"""Controls the HUPCL"""
if platform.system() == "Linux":
......@@ -97,6 +106,7 @@ class printcore():
self.online = False
self.printing = False
@locked
def connect(self, port = None, baud = None):
"""Set port and baudrate if given, then connect to printer
"""
......
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