-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap the interruption to a custom exception when a blocking API is in…
…terrupted (#99) ### Motivation Currently, when a blocking API is interrupted by a signal, `SystemError` will be thrown. However, in this case, `PyErr_SetInterrupt` will be called and next time a blocking API is called, `std::system_error` will be somehow thrown. The failure of https://lists.apache.org/thread/cmzykd9qz9x1d0s35nc5912o3slwpxpv is caused by this issue. The `SystemError` is not called, then `client.close()` will be skipped, which leads to the `bad_weak_ptr` error. P.S. Currently we have to call `client.close()` on a `Client` instance, otherwise, the `bad_weak_ptr` will be thrown. However, even if we caught the `SystemError` like: ```python try: msg = consumer.receive() # ... except SystemError: break ``` we would still see the following error: ``` terminate called after throwing an instance of 'std::system_error' what(): Operation not permitted Aborted ``` ### Modifications - Wrap `ResultInterrupted` into the `pulsar.Interrupted` exception. - Refactor the `waitForAsyncValue` and `waitForAsyncResult` functions and raise `pulsar.Interrupted` when `PyErr_CheckSignals` detects a signal. - Add `InterruptedTest` to cover this case. - Remove `future.h` since we now use `std::future` instead of the manually implemented `Future`. - Fix the `examples/consumer.py` to support stopping by Ctrl+C. (cherry picked from commit ec05f50)
- Loading branch information
1 parent
9ed92ec
commit b883f42
Showing
11 changed files
with
121 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.