Skip to content

avoid recursion if init called more than one time#408

Open
maliubiao wants to merge 1 commit into
tartley:masterfrom
maliubiao:master
Open

avoid recursion if init called more than one time#408
maliubiao wants to merge 1 commit into
tartley:masterfrom
maliubiao:master

Conversation

@maliubiao
Copy link
Copy Markdown

if _initialized:
    raise ValueError("Calling init() twice will result in recursion.")
if not _initialized:
    _initialized = True
  • Logic: Ensures init() is called only once. Re-initialization would cause recursion (wrapped streams re-wrap themselves).

   ```python
   if _initialized:
       raise ValueError("Calling init() twice will result in recursion.")
   if not _initialized:
       _initialized = True
   ```
   - **Logic**: Ensures `init()` is called only once. Re-initialization would cause recursion (wrapped streams re-wrap themselves).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant