| 1327 | return _BufferedIOMixin.seek(self, pos, whence) |
| 1328 | |
| 1329 | def close(self): |
| 1330 | with self._write_lock: |
| 1331 | if self.raw is None or self.closed: |
| 1332 | return |
| 1333 | # We have to release the lock and call self.flush() (which will |
| 1334 | # probably just re-take the lock) in case flush has been overridden in |
| 1335 | # a subclass or the user set self.flush to something. This is the same |
| 1336 | # behavior as the C implementation. |
| 1337 | try: |
| 1338 | # may raise BlockingIOError or BrokenPipeError etc |
| 1339 | self.flush() |
| 1340 | finally: |
| 1341 | with self._write_lock: |
| 1342 | self.raw.close() |
| 1343 | |
| 1344 | |
| 1345 | class BufferedRWPair(BufferedIOBase): |