Returning intermediate result during function call
See original GitHub issueI’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:
- Created 3 years ago
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the front end you have to add an exposed JS function that does what you want. Like:
In your backend, call that function when
Let me know if you still need help 😃
I’m going to close this due to inactivity - hopefully you’ve worked it out now from the help provided 😃