Destroys a stopped Automaton: this cleanups all opened file descriptors. Required on PyPy for instance where the garbage collector behaves differently.
(self)
| 1565 | cmd.clear() |
| 1566 | |
| 1567 | def destroy(self): |
| 1568 | # type: () -> None |
| 1569 | """ |
| 1570 | Destroys a stopped Automaton: this cleanups all opened file descriptors. |
| 1571 | Required on PyPy for instance where the garbage collector behaves differently. |
| 1572 | """ |
| 1573 | if not hasattr(self, "started"): |
| 1574 | return # was never started. |
| 1575 | if self.isrunning(): |
| 1576 | raise ValueError("Can't close running Automaton ! Call stop() beforehand") |
| 1577 | # Close command pipes |
| 1578 | self.cmdin.close() |
| 1579 | self.cmdout.close() |
| 1580 | self._flush_inout() |
| 1581 | # Close opened ioins/ioouts |
| 1582 | for i in itertools.chain(self.ioin.values(), self.ioout.values()): |
| 1583 | if isinstance(i, ObjectPipe): |
| 1584 | i.close() |
| 1585 | |
| 1586 | def stop(self, wait=True): |
| 1587 | # type: (bool) -> None |