Skip to content

Commit

Permalink
NXDRIVE-1482: Do not raise error on null thread id
Browse files Browse the repository at this point in the history
  • Loading branch information
Léa Klein authored and LKleinNux committed Dec 21, 2018
1 parent ac6d17d commit 87bb0e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/changes/4.0.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Release date: `201x-xx-xx`
- [NXDRIVE-1479](https://jira.nuxeo.com/browse/NXDRIVE-1479): Handle Direct Edits with no xpath
- [NXDRIVE-1480](https://jira.nuxeo.com/browse/NXDRIVE-1480): Add "file" to ignored options
- [NXDRIVE-1481](https://jira.nuxeo.com/browse/NXDRIVE-1481): Do not disclose the token in logs
- [NXDRIVE-1482](https://jira.nuxeo.com/browse/NXDRIVE-1482): Do not raise error on null thread id

## GUI

Expand Down
9 changes: 5 additions & 4 deletions nxdrive/engine/dao/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,8 @@ def _init_db(self, cursor: Cursor) -> None:
)
self._create_state_table(cursor)

def acquire_state(self, thread_id: int, row_id: int) -> Optional[DocPair]:
if self.acquire_processor(thread_id, row_id):
def acquire_state(self, thread_id: Optional[int], row_id: int) -> Optional[DocPair]:
if thread_id is not None and self.acquire_processor(thread_id, row_id):
# Avoid any lock for this call by using the write connection
try:
return self.get_state_from_id(row_id, from_write=True)
Expand All @@ -620,8 +620,9 @@ def acquire_state(self, thread_id: int, row_id: int) -> Optional[DocPair]:
raise
raise OperationalError("Cannot acquire")

def release_state(self, thread_id: int) -> None:
self.release_processor(thread_id)
def release_state(self, thread_id: Optional[int]) -> None:
if thread_id is not None:
self.release_processor(thread_id)

def release_processor(self, processor_id: int) -> bool:
with self._lock:
Expand Down
4 changes: 1 addition & 3 deletions nxdrive/engine/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ def quit(self) -> None:

self._continue = False

def get_thread_id(self) -> int:
def get_thread_id(self) -> Optional[int]:
""" Get the thread ID. """
if not self._thread_id:
raise RuntimeError("Unable to retrieve thread id")
return self._thread_id

def _interact(self) -> None:
Expand Down

0 comments on commit 87bb0e0

Please sign in to comment.