forked from official-stockfish/fishtest
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement bulk streaming of tasks PGNs for a run
This commit adds a feature that streams PGNs of a run, significantly reducing the server's CPU/RAM usage. The API now returns a gzipped PGN, constructed by chaining all the run's gzipped PGNs, which is streamed to the client. Key changes: 1. update 'api_download_run_pgns' in api.py, which handles the request for downloading the PGN of the run. It fetches the PGNs using the 'get_run_pgns' method from the RunDb class, and returns a gzipped response ``` wget https://test.stockfishchess.org/api/run_pgns/<run_id>.pgn.gz ``` 2. add 'GeneratorAsFileReader' class in util.py that provides a file-like interface for a generator, enabling chanked reading 3. modify the 'get_run_pgns' method in rundb.py to return a 'GeneratorAsFileReader' object that yields each gzipped PGN file for the run Note: the `gunzip on;` directive must be removed from the nginx configuration. Improvement suggested by @peregrineshahin
- Loading branch information
1 parent
e5e1ae7
commit e29e3fa
Showing
3 changed files
with
32 additions
and
24 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