Run operations of `fetches`. Args: fetches: :class:`Operation` Raises: RuntimeError: Client disconnect to the service. Or run on a closed session. ValueError: If fetch is not an instance of :class:`Operation`. Or
(self, fetches)
| 832 | return dag_node |
| 833 | |
| 834 | def run(self, fetches): |
| 835 | """Run operations of `fetches`. |
| 836 | Args: |
| 837 | fetches: :class:`Operation` |
| 838 | |
| 839 | Raises: |
| 840 | RuntimeError: |
| 841 | Client disconnect to the service. Or run on a closed session. |
| 842 | |
| 843 | ValueError: |
| 844 | If fetch is not an instance of :class:`Operation`. Or |
| 845 | the fetch has been evaluated. |
| 846 | |
| 847 | InvalidArgumentError: |
| 848 | Not recognized on output type. |
| 849 | |
| 850 | Returns: |
| 851 | Different values for different output types of :class:`Operation` |
| 852 | """ |
| 853 | |
| 854 | # There might be a deadlock without `gc.collect()`: |
| 855 | # |
| 856 | # - thread 1 uses `run()` to issue grpc requests |
| 857 | # - during the process, e.g., print traceback, it triggers certain `__del__()` |
| 858 | # and that issues a `run_fetches()` again, that further requires the lock |
| 859 | # - then a deadlock been introduced. |
| 860 | # |
| 861 | # Thus, we simply choose to call `gc.collect()` to force those `__del__()` been |
| 862 | # invoked before actually issuing the grpc request to avoid the deadlock. |
| 863 | # |
| 864 | gc.collect() |
| 865 | |
| 866 | with self._lock: |
| 867 | return self.run_fetches(fetches) |
| 868 | |
| 869 | def run_fetches(self, fetches): |
| 870 | """Run operations of `fetches` without the session lock.""" |
no test coverage detected