Commit cd8ce260 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Make initialization of CamrasHpibDevice thread safe

parent bf072b26
......@@ -54,17 +54,20 @@ from astropy.units import Quantity
import hpib
import serial.threaded
import threading
class CamrasHpibDevice(object):
"""Wrapper around HPIB commands"""
command_thread = None
_initialization_lock = threading.Lock()
def __init__(self, address, check_frequency=True):
self.hpib_address = address
self._check_frequency = check_frequency
with self._initialization_lock:
if not CamrasHpibDevice.command_thread:
serial_port = serial.Serial("/dev/ttyUSB0")
CamrasHpibDevice.command_thread = serial.threaded.ReaderThread(serial_port,
......
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