| 18 | |
| 19 | |
| 20 | class BlockTimeout: # pragma: no unittest |
| 21 | def __init__( |
| 22 | self, |
| 23 | exception_to_throw: Exception, |
| 24 | raiden: RaidenService, |
| 25 | block_number: BlockNumber, |
| 26 | retry_timeout: float, |
| 27 | ) -> None: |
| 28 | self.exception_to_throw = exception_to_throw |
| 29 | self.raiden = raiden |
| 30 | self.block_number = block_number |
| 31 | self.retry_timeout = retry_timeout |
| 32 | self._task: Optional[Greenlet] = None |
| 33 | |
| 34 | def __enter__(self) -> None: |
| 35 | self._task = gevent.spawn( |
| 36 | _timeout_task, |
| 37 | gevent.getcurrent().throw, |
| 38 | self.exception_to_throw, |
| 39 | self.raiden, |
| 40 | self.block_number, |
| 41 | self.retry_timeout, |
| 42 | ) |
| 43 | self._task.name = "timout_task" |
| 44 | |
| 45 | def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: |
| 46 | if self._task: |
| 47 | self._task.kill() |
no outgoing calls