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

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

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