question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

STDOUT WorkflowException issue

See original GitHub issue

Ok… stay with me here. I have a framework that interacts with different ‘node servers’ via STDIN and STDOUT and some other stuff.

I’m using your LIFXLAN module inside one of these node servers and it queries the light every 30 seconds. It creates a new class for each light and runs as a daemon.

My specific issue:

lifx = lifxlan.LifxLAN(None)
devices = lifx.get_lights()
for d in devices:
    while True:
        try:
            power = True if d.get_power() == 65535 else False
        except (lifxlan.device.WorkflowException):
            print 'The device is offline'
        time.sleep(30)

When I try to catch lifxlan.device.WorkflowException, no matter what I do it ALWAYS outputs to STDOUT. This actually breaks my framework. Instead of actually catching the exception, I get this to STDOUT:

WorkflowException: Did not receive <class 'lifxlan.msgtypes.LightStatePower'> in response to <class 'lifxlan.msgtypes.LightGetPower'>

My question is how the heck can I catch your custom exception from device.py without outputting to STDOUT? I’m sure it’s my ignorance, hope this is an easy question and I’m just missing something.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mclarkkcommented, Feb 16, 2017

The issue is in light.py:

def get_power(self):
        try:
            response = self.req_with_resp(LightGetPower, LightStatePower)
            self.power_level = response.power_level
        except WorkflowException as e:
            print(e)
        return self.power_level

I changed print(e) to pass and that stopped the message from printing, surprise surprise. Of course, the better design would be to raise all the way up through the module to the user’s code, because the user may want their application logic to be different if the light goes offline.

There are actually a lot of places where the lifxlan code either silently catches an error or prints out the error message, which I agree is really obnoxious as a user. I’ll go through the code base and turn all those into re-raises. Then your code would be able to catch and handle the WorkflowException.

Thanks for pointing this out, in retrospect those were some pretty silly design decisions on my part. I’ll go through and make sure everywhere in the module where something gets printed out, it is only when the verbose flag has been intentionally set by the user.

0reactions
Einstein42commented, Jun 26, 2017

I was very slow to respond on this. I really appreciate your efforts. This is an absolutely fantastic module.

Read more comments on GitHub >

github_iconTop Results From Across the Web

misleading error message when string is passed where File is ...
When a string type parameter is passed and a File or Directory is expected, cwltool should tell the user that the input parameter...
Read more >
Databricks notebook time out error when calling other ...
I fixed the problem by tuning the default spark configuration. I increase the executor heartbeat and the networko spark.executor.heartbeat ...
Read more >
RE: Kaleo workflow Oracle 10g problem [SOLVED] - Forums
Hi again! We're using Liferay 6 without bundle, during the instalation we copied the kaleo-web.war from a bundle instalation to the new deploy...
Read more >
UserTask running on OraBPEL 10.1.3 - Oracle Communities
Hi all.. I have some bpel process with user task, designed with Jdev 10.1.2 and correctly runnign into OracleBPEL 10.1.2 for JBoss .....
Read more >
common-workflow-language/common-workflow-language
WorkflowException: Invalid job input record: test.yml:2:1: the `fastqs` field is ... Step_$(inputs.step)_QualityControl] outputs: info: type: stdout error: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found