Skip to content

Commit

Permalink
When updating within a ContentItem, use the fully returned result
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Nov 13, 2024
1 parent 137ba8b commit f70ebaa
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/posit/connect/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ def render(self) -> Task:
--------
>>> render()
"""
self.update() # pyright: ignore[reportCallIssue]
full_content_item: ContentItem = self.update() # pyright: ignore[reportCallIssue]

if self.is_rendered:
variants = self._variants.find()
if full_content_item.is_rendered:
variants = full_content_item._variants.find()
variants = [variant for variant in variants if variant["is_default"]]
if len(variants) != 1:
raise RuntimeError(
Expand All @@ -243,16 +243,18 @@ def restart(self) -> None:
--------
>>> restart()
"""
self.update() # pyright: ignore[reportCallIssue]
full_content_item: ContentItem = self.update() # pyright: ignore[reportCallIssue]

if self.is_interactive:
if full_content_item.is_interactive:
unix_epoch_in_seconds = str(int(time.time()))
key = f"_CONNECT_RESTART_TMP_{unix_epoch_in_seconds}"
self.environment_variables.create(key, unix_epoch_in_seconds)
self.environment_variables.delete(key)
full_content_item.environment_variables.create(key, unix_epoch_in_seconds)
full_content_item.environment_variables.delete(key)
# GET via the base Connect URL to force create a new worker thread.
url = posixpath.join(dirname(self._ctx.url), f"content/{self['guid']}")
self._ctx.session.get(url)
url = posixpath.join(
dirname(full_content_item._ctx.url), f"content/{full_content_item['guid']}"
)
full_content_item._ctx.session.get(url)
return None
else:
raise ValueError(
Expand Down

0 comments on commit f70ebaa

Please sign in to comment.