| 1302 | return _BufferedIOMixin.seek(self, pos, whence) |
| 1303 | |
| 1304 | def close(self): |
| 1305 | with self._write_lock: |
| 1306 | if self.raw is None or self.closed: |
| 1307 | return |
| 1308 | # We have to release the lock and call self.flush() (which will |
| 1309 | # probably just re-take the lock) in case flush has been overridden in |
| 1310 | # a subclass or the user set self.flush to something. This is the same |
| 1311 | # behavior as the C implementation. |
| 1312 | try: |
| 1313 | # may raise BlockingIOError or BrokenPipeError etc |
| 1314 | self.flush() |
| 1315 | finally: |
| 1316 | with self._write_lock: |
| 1317 | self.raw.close() |
| 1318 | |
| 1319 | |
| 1320 | class BufferedRWPair(BufferedIOBase): |