add documentation

This commit is contained in:
Mira Weller
2024-04-30 21:49:58 +02:00
parent 00dd1a5b31
commit 569f1719b0
2 changed files with 7 additions and 0 deletions
@@ -10,6 +10,8 @@ product can be bought, you should use :py:meth:`time_machine_now`.
.. autofunction:: pretix.base.timemachine.time_machine_now
.. autofunction:: pretix.base.timemachine.time_machine_now_assigned
Background tasks
----------------
+5
View File
@@ -60,6 +60,11 @@ def time_machine_now(default=False):
@contextmanager
def time_machine_now_assigned(now_dt):
"""
Use this context manager to assign current datetime for time machine mode. Useful e.g. for background tasks.
:param now_dt: The datetime value to assign. May be `None` to disable time machine.
"""
try:
timemachine_now_var.set(now_dt)
yield