Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions base_contextvars/contextvars_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@

@classproperty
def contextvars_envs(_cls):
# Look in _local in case we use this while the non patched context manager is active
return _odoo_environments_ctx.get() or getattr(_cls._local, "environments", ())
result = _odoo_environments_ctx.get() or getattr(_cls._local, "environments", None)
if not result:
result = Environments()
_odoo_environments_ctx.set(result)
return result


@classmethod # type: ignore
Expand All @@ -36,7 +39,7 @@ def contextvars_manage(_cls):
yield
finally:
_logger.debug("envs manage end")
_odoo_environments_ctx.set(())
_odoo_environments_ctx.set(None)


@classmethod # type: ignore
Expand Down
Loading