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

Bugfix: Proper async_call error/exception handling #65

Conversation

dh377
Copy link
Contributor

@dh377 dh377 commented Mar 4, 2022

QRateLimitedExecutor wrapping functions like RateLimitedCommRqData, RateLimitedCommKwRqData, RateLimitedSendOrder, RateLimitedSendCondition return concurrent.futures.Future object immediately upon asynchronous execution with async_call.

Therefore, the result after execution should be returned by attaching callback functions 1, 2 to the Future object. However, the callback implementation contained in try_or_raise currently does not have a way to properly handle an error or an exception in the function return.

For example, if an error or exception occurs between immediately after the execution of a function and before the event begins to return, there is no way on the server side to notify the client that there is an error, and the client will continue to wait for the next message. I found this attempt, but this is an invalid exception handling method for async_call returning a Future object.

In this pull request, the except_callback argument to receive the exception object when an error or exception occurs was added to try_or_raise, and I tried to find a place where it can be used and apply it all.

@codecov
Copy link

codecov bot commented Mar 4, 2022

Codecov Report

Merging #65 (f38bf26) into master (69ca07a) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #65      +/-   ##
=========================================
- Coverage    6.33%   6.32%   -0.01%     
=========================================
  Files         203     203              
  Lines       12812   12821       +9     
=========================================
  Hits          811     811              
- Misses      12001   12010       +9     
Flag Coverage Δ
windows-latest-py3.8 6.32% <0.00%> (-0.01%) ⬇️
windows-latest-py3.9 6.30% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...iwoom_open_api_plus/core/KiwoomOpenApiPlusError.py 0.00% <0.00%> (ø)
...pc/event/KiwoomOpenApiPlusConditionEventHandler.py 0.00% <ø> (ø)
...us/grpc/event/KiwoomOpenApiPlusKwTrEventHandler.py 0.00% <ø> (ø)
...s/grpc/event/KiwoomOpenApiPlusOrderEventHandler.py 0.00% <ø> (ø)
...plus/grpc/event/KiwoomOpenApiPlusTrEventHandler.py 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 69ca07a...f38bf26. Read the comment docs.

@dh377 dh377 changed the title Proper async_call error/exception handling Bugfix: Proper async_call error/exception handling Mar 5, 2022
@elbakramer elbakramer merged commit 972283e into elbakramer:master Mar 23, 2022
@dh377 dh377 deleted the bugfix/proper_async_call_error_exception_handling branch March 23, 2022 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants