Thread-safely add an item to the list. Args: item: The item to add to the list.
(self, item: T)
| 113 | return value if value is not None else [] |
| 114 | |
| 115 | def add(self, item: T) -> None: |
| 116 | """Thread-safely add an item to the list. |
| 117 | |
| 118 | Args: |
| 119 | item: The item to add to the list. |
| 120 | """ |
| 121 | with self._lock: |
| 122 | current_list = self.get() |
| 123 | if not any(x is item for x in current_list): |
| 124 | new_list = current_list + [item] |
| 125 | self._context_var.set(new_list) |
| 126 | |
| 127 | def remove(self, item: T) -> None: |
| 128 | """Thread-safely remove an item from the list. |