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