Skip to content

Commit 566118a

Browse files
author
Jongmin Kim
authored
Merge pull request #71 from whdalsrnt/master
Refactor Transaction
2 parents 8c3eea2 + e6acba1 commit 566118a

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/spaceone/core/base.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ class CoreObject(object):
66

77
def __init__(self, *args, **kwargs):
88
self.locator = Locator()
9-
self.transaction_id = None
9+
get_transaction()
1010

1111
@property
1212
def transaction(self) -> Transaction:
13-
transaction = get_transaction()
14-
if transaction:
15-
self.transaction_id = transaction.id
16-
17-
return transaction
13+
return get_transaction()

src/spaceone/core/transaction.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,7 @@ def delete_transaction() -> None:
134134
if transaction := get_transaction(is_create=False):
135135
if hasattr(LOCAL_STORAGE, transaction.id):
136136
delattr(LOCAL_STORAGE, transaction.id)
137-
elif hasattr(LOCAL_STORAGE, transaction.thread_id):
138-
delattr(LOCAL_STORAGE, transaction.thread_id)
137+
138+
thread_id = str(threading.current_thread().ident)
139+
if hasattr(LOCAL_STORAGE, thread_id):
140+
delattr(LOCAL_STORAGE, thread_id)

0 commit comments

Comments
 (0)