Open fcavalieri opened 3 years ago
@fcavalieri thanks for noting this.
To answer your final question: you are doing nothing wrong, and yet at the same time there is no actual issue. The problem is one of wrong expectations: the event interception mechanism works only for the generator (i.e., sync) functions. This is not really stated in the documentation though, and that's something I can fix right now.
In the future it should be possible to implement event interception for the async functions I think, but that would require some more work. I'll change the title of this issue to reflect the lack of this feature, but other than that I can't promise this is something I'll be doing any time soon.
I am trying to implement the Intercepting Events pattern from https://github.com/ICRAR/ijson#id13 to consume an aiohttp response. When using non-async sources everything works as expected.
Running Python 3.9.4 (on Kubuntu 20.04), ijson 3.1.4, aiohttp 3.7.4.post0. For the sake of testing all backends i also installed cffi 1.14.5, and the OS package libyajl2:amd64 2.1.0-3. The precise versions do not seem crucial. The code below uses a json file from the web, the specific json data is not important. The path specified in the code is not important either.
1, 2, and 3 work fine. 4 raises various exceptions depending on the backend:
I tried a few combinations of parse_async/parse/items_async/items/async for/for, but without luck.
Am i doing something wrong or is there an issue?