admin管理员组文章数量:1400117
I'm creating a subclass of s3fs.S3FileSystem
that connects to either AWS S3 or MinIO based on environment variables. The connection should fail immediately during initialization if credentials are invalid.
The parent class accepts invalid credentials during initialization, only failing later during actual operations (like ls()
or file access).
When I try to validate the connection by calling self.ls('')
inside __init__
(via a _test_connection()
helper), I get a NotImplementedError
. However, if I call the same method after instantiation, it works correctly.
class S3MinioConnector(s3fs.S3FileSystem):
def __init__(self) -> None:
# ... (setup code)
super().__init__(**params) # Initialize parent
self._test_connection() # Fails here with NotImplementedError
def _test_connection(self):
self.ls('') # Inherited method
How can I properly validate the connection during initialization without:
Getting
NotImplementedError
?Using obscure solutions like
time.sleep(2)
?
本文标签:
版权声明:本文标题:python 3.x - NotImplementedError when testing S3 connection during __init__ in s3fs.S3FileSystem subclass - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744192045a2594561.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论