Serialize State for sending to build worker. Note that unlike write() methods for most other classes, this one is not idempotent. We erase some bulky values that should either be not needed for processing by the worker, or can be re-created from other data relatively
(self, buf: WriteBuffer)
| 2910 | self.needs_parse = False |
| 2911 | |
| 2912 | def write(self, buf: WriteBuffer) -> None: |
| 2913 | """Serialize State for sending to build worker. |
| 2914 | |
| 2915 | Note that unlike write() methods for most other classes, this one is |
| 2916 | not idempotent. We erase some bulky values that should either be not needed |
| 2917 | for processing by the worker, or can be re-created from other data relatively |
| 2918 | quickly. These are: |
| 2919 | * self.meta: workers will call self.reload_meta() anyway. |
| 2920 | * self.options: can be restored with Options.clone_for_module(). |
| 2921 | * self.error_lines: fresh errors are handled by the coordinator. |
| 2922 | """ |
| 2923 | write_int(buf, self.order) |
| 2924 | write_str(buf, self.id) |
| 2925 | write_str_opt(buf, self.path) |
| 2926 | write_str_opt(buf, self.source) # mostly for mypy -c '<some code>' |
| 2927 | write_bool(buf, self.ignore_all) |
| 2928 | write_int(buf, self.caller_line) |
| 2929 | write_tag(buf, LIST_GEN) |
| 2930 | write_int_bare(buf, len(self.import_context)) |
| 2931 | for path, line in self.import_context: |
| 2932 | write_str(buf, path) |
| 2933 | write_int(buf, line) |
| 2934 | write_bytes(buf, self.interface_hash) |
| 2935 | write_str_opt(buf, self.meta_source_hash) |
| 2936 | write_str_list(buf, self.dependencies) |
| 2937 | write_str_list(buf, self.suppressed) |
| 2938 | # TODO: we can possibly serialize these dictionaries in a more compact way. |
| 2939 | # Most keys in the dictionaries should be the same, so we can write them once. |
| 2940 | write_tag(buf, DICT_STR_GEN) |
| 2941 | write_int_bare(buf, len(self.priorities)) |
| 2942 | for mod_id, prio in self.priorities.items(): |
| 2943 | write_str_bare(buf, mod_id) |
| 2944 | write_int(buf, prio) |
| 2945 | write_tag(buf, DICT_STR_GEN) |
| 2946 | write_int_bare(buf, len(self.dep_line_map)) |
| 2947 | for mod_id, line in self.dep_line_map.items(): |
| 2948 | write_str_bare(buf, mod_id) |
| 2949 | write_int(buf, line) |
| 2950 | write_tag(buf, DICT_STR_GEN) |
| 2951 | write_int_bare(buf, len(self.dep_hashes)) |
| 2952 | for mod_id, dep_hash in self.dep_hashes.items(): |
| 2953 | write_str_bare(buf, mod_id) |
| 2954 | write_bytes(buf, dep_hash) |
| 2955 | write_int(buf, self.size_hint) |
| 2956 | |
| 2957 | @classmethod |
| 2958 | def read(cls, buf: ReadBuffer, manager: BuildManager) -> State: |
no test coverage detected