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.

Returning intermediate result during function call

See original GitHub issue

I’m trying to figure out how or maybe if it is possible to return some sort of information when python function is being called and is running some loop that has variable which is incremented. Lets say I have a function that saves a file to a excel file:

@eel.expose
def xlsx_converter(path, sheet, output):
        start = time.process_time()
        wb =  openpyxl.load_workbook("input/" + path, read_only=True) 
        ws = wb[sheet]
        row_count = ws.max_row
        with open("input/"+output, "w") as out:
            writer = csv.writer(out)
            counter = 0
            for row in ws:
                if counter/row_count == 0.5:
                        #return "Intermediate result message-info"
                elif counter/row_count == 0.75: 
                       #return "Another Intermediate result message-info"
                else:
                        continue
                values = (cell.value for cell in row)
                writer.writerow(values)
                counter+=1

So given some condition (when the counter variable reaches some value) I would like to send that msg to my frontend. Is this possibility? How would I retrieve this in frontend?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
NecroticOozecommented, May 15, 2020

In the front end you have to add an exposed JS function that does what you want. Like:

eel.expose(myFunc)
function myFunc() { //Do something}

In your backend, call that function when

if counter == 99: #or whatever value
     eel.myFunc()
else:
     pass

Let me know if you still need help 😃

0reactions
samuelhwilliamscommented, Jul 9, 2020

I’m going to close this due to inactivity - hopefully you’ve worked it out now from the help provided 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Returning intermediate results from function in Python
Show activity on this post. returns the same answer 6 and inserts the intermediate calculations into the supplied dictionary. Save this answer. ...
Read more >
Intermediate results returned by User Defined Functions (UDF ...
I recreate all the functions again. "the usernames() function is created after both of the above". When I try to execute all the...
Read more >
[R] save intermediate result
Break your long running function into two parts. The first will be the long running part and it can return a value that...
Read more >
Continuation-passing style - Wikipedia
When the CPS function has computed its result value, it "returns" it by calling the continuation function with this value as the argument....
Read more >
LLVM Language Reference Manual
This allows LLVM to provide a powerful intermediate representation for efficient ... This doesn't apply for values returned in callee-saved registers.
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