11import collections
22import inspect
33import io
4- import threading
54import weakref
65from typing import (
76 Any ,
1716
1817from typing_extensions import Self
1918
19+ from robotcode .core .concurrent import RLock
2020from robotcode .core .event import event
2121from robotcode .core .lsp .types import DocumentUri , Position , Range
2222from robotcode .core .uri import Uri
@@ -85,7 +85,7 @@ class CacheEntry:
8585 def __init__ (self ) -> None :
8686 self .data : Any = None
8787 self .has_data : bool = False
88- self .lock = threading . RLock ()
88+ self .lock = RLock (name = "Document.CacheEntry.lock" , default_timeout = 120 )
8989
9090
9191class TextDocument :
@@ -100,7 +100,7 @@ def __init__(
100100 ) -> None :
101101 super ().__init__ ()
102102
103- self ._lock = threading . RLock ()
103+ self ._lock = RLock (name = f"Document.lock ' { document_uri } '" , default_timeout = 120 )
104104 self .document_uri = document_uri
105105 self .uri = Uri (self .document_uri ).normalized ()
106106 self .language_id = language_id
@@ -110,7 +110,7 @@ def __init__(
110110 self ._orig_version = version
111111 self ._lines : Optional [List [str ]] = None
112112 self ._cache : Dict [weakref .ref [Any ], CacheEntry ] = collections .defaultdict (CacheEntry )
113- self ._data_lock = threading . RLock ()
113+ self ._data_lock = RLock (name = f"Document.data_lock ' { document_uri } '" , default_timeout = 120 )
114114 self ._data : weakref .WeakKeyDictionary [Any , Any ] = weakref .WeakKeyDictionary ()
115115 self .opened_in_editor = False
116116
0 commit comments