consumer-producer problem
miurahr opened this issue · comments
Describe the bug
Decompressor become wrong status when memory_size is smaller than file size.
Related issue
#25
To Reproduce
The test has already merged into main branch.
Expected behavior
PyPPMd should handle it correctly.
Environment:
- OS: no dependency
- Python: all python versions
- project version: all released versions, main branch.
Additional context
The root cause is the producer-consumer problem. Now producer use Python buffer protocol that provide a buffer, but consumer expect it can read arbitrary data from buffer.
The solution is to run the library code,consumer, in another thread and stop and wait when input buffer is exhausted.
When returns to caller code by need-input-data status, it go back to user python code and wait a next call, and when input is given, it wake the library code to continue.