Skip to content

Commit

Permalink
table: prevent deadlock in _init_ids
Browse files Browse the repository at this point in the history
The previous version used obj.X.shape inside the locked part, but the
problem was that SqlTable downloaded data when .X was accessed, which in
turn run another _init_ids within. Now deadlocks should be impossible as
the locked part only deals with primitive variables.
  • Loading branch information
markotoplak committed Sep 1, 2023
1 parent 4089bc0 commit 123c56f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Orange/data/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,10 +1009,11 @@ def from_list(cls, domain, rows, weights=None):

@classmethod
def _init_ids(cls, obj):
length = int(obj.X.shape[0])
with cls._next_instance_lock:
nid = cls._next_instance_id
cls._next_instance_id += obj.X.shape[0]
obj.ids = np.arange(nid, nid + obj.X.shape[0], dtype=int)
cls._next_instance_id += length
obj.ids = np.arange(nid, nid + length, dtype=int)

@classmethod
def new_id(cls):
Expand Down

0 comments on commit 123c56f

Please sign in to comment.