Skip to content

Commit

Permalink
Destroy Registry Flag (#162)
Browse files Browse the repository at this point in the history
This provides a public interface to destroy the DBOS class with
`DBOS.destroy()` without destroying the registry of decorated functions.
Useful for re-launching after failures.

Addresses #160
  • Loading branch information
kraftp authored Nov 30, 2024
1 parent d3cd06f commit c676ff0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dbos/_dbos.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,14 @@ def __new__(
return _dbos_global_instance

@classmethod
def destroy(cls) -> None:
def destroy(cls, *, destroy_registry: bool = True) -> None:
global _dbos_global_instance
global _dbos_global_registry
if _dbos_global_instance is not None:
_dbos_global_instance._destroy()
_dbos_global_instance = None
_dbos_global_registry = None
if destroy_registry:
global _dbos_global_registry
_dbos_global_registry = None

def __init__(
self,
Expand Down

0 comments on commit c676ff0

Please sign in to comment.