Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Begin timeout #66

Merged
merged 4 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions pcdsdaq/daq.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,19 @@ def kickoff(self, events=None, duration=None, use_l3t=None, controls=None):
logger.debug(err, exc_info=True)
raise StateTransitionError(err)

def start_thread(control, status, events, duration, use_l3t, controls):
if self.state == 'Configured' and self.config['record']:
try:
prev_run = self.run_number()
next_run = prev_run + 1
except (RuntimeError, ValueError):
logger.debug('Error getting run number in kickoff',
exc_info=True)
next_run = None
ZryletTC marked this conversation as resolved.
Show resolved Hide resolved
else:
next_run = None

def start_thread(control, status, events, duration, use_l3t, controls,
run_number):
tmo = self._begin_timeout
dt = 0.1
logger.debug('Make sure daq is ready to begin')
Expand All @@ -422,14 +434,9 @@ def start_thread(control, status, events, duration, use_l3t, controls):
if self.state in ('Configured', 'Open'):
begin_args = self._begin_args(events, duration, use_l3t,
controls)
if self.config['record']:
try:
prev_run = self.run_number()
next_run = prev_run + 1
logger.info('Beginning daq run %s', next_run)
except (RuntimeError, ValueError):
logger.debug('Error getting run number in kickoff',
exc_info=True)
if run_number is not None:
logger.info('Beginning daq run %s', run_number)

logger.debug('daq.control.begin(%s)', begin_args)
dt = time.time() - self._last_stop
tmo = BEGIN_THROTTLE - dt
Expand All @@ -448,7 +455,8 @@ def start_thread(control, status, events, duration, use_l3t, controls):
begin_status = Status(obj=self)
watcher = threading.Thread(target=start_thread,
args=(self._control, begin_status, events,
duration, use_l3t, controls))
duration, use_l3t, controls,
next_run))
watcher.start()
return begin_status

Expand Down
12 changes: 6 additions & 6 deletions pcdsdaq/ext_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ def call_script(args, timeout=None, ignore_return_code=False):
raise


def hutch_name():
def hutch_name(timeout=5):
script = SCRIPTS.format('latest', 'get_hutch_name')
name = call_script(script)
name = call_script(script, timeout=timeout)
return name.lower().strip(' \n')


def get_run_number(hutch=None, live=False):
def get_run_number(hutch=None, live=False, timeout=5):
latest = hutch or 'latest'
script = SCRIPTS.format(latest, 'get_lastRun')
args = [script]
if hutch is not None:
args += ['-i', hutch]
if live:
args += ['-l']
run_number = call_script(args)
run_number = call_script(args, timeout=timeout)
return int(run_number)


def get_ami_proxy(hutch):
def get_ami_proxy(hutch, timeout=2):
# This is mostly copied from old hutch python verbatim
# I don't have useful explanations for what these regular expressions
# are used for
Expand All @@ -56,7 +56,7 @@ def get_ami_proxy(hutch):
cnf = CNF.format(hutch)
procmgr = TOOLS.format('procmgr', 'procmgr')
output = call_script([procmgr, 'status', cnf, 'ami_proxy'],
timeout=2,
timeout=timeout,
ignore_return_code=True)
for line in output.split('\n'):
ip_match = ip_re.match(line)
Expand Down