Skip to content

Handle BrokenPipeError #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions pythonx/async_clj_omni/cider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ def candidate(val):
"menu": " ".join(arglists) if arglists else ""
}

def rethrow(e):
raise e

def cider_gather(logger, nrepl, keyword, session, ns):
def cider_gather(logger, nrepl, keyword, session, ns, on_error=rethrow):
# Should be unique for EVERY message
msgid = uuid.uuid4().hex

Expand All @@ -50,15 +52,18 @@ def completion_callback(cmsg, cwc, ckey):

logger.debug("cider_gather watching msgid")

# TODO: context for context aware completions
nrepl.send({
"id": msgid,
"op": "complete",
"session": session,
"symbol": keyword,
"extra-metadata": ["arglists", "doc"],
"ns": ns
})
try:
# TODO: context for context aware completions
nrepl.send({
"id": msgid,
"op": "complete",
"session": session,
"symbol": keyword,
"extra-metadata": ["arglists", "doc"],
"ns": ns
})
except BrokenPipeError as e:
on_error(e)

completion_event.wait(0.5)

Expand Down
13 changes: 12 additions & 1 deletion pythonx/async_clj_omni/fireplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def global_watch(cmsg, cwc, ckey):

return self.__conns.get(conn_string)

def remove_conn(self, conn_string):
self.logger.debug(
("Connection to {} died. "
"Removing the connection.").format(conn_string)
)
self.__conns.pop(conn_string, None)

class Fireplace_nrepl:
def __init__(self, wc):
self.wc = wc
Expand Down Expand Up @@ -80,8 +87,12 @@ def gather_candidates(self, complete_str):

wc = self.__connmanager.get_conn(conn_string)

def on_error(e):
self.__connmanager.remove_conn(conn_string)

return cider_gather(self.__logger,
Fireplace_nrepl(wc),
complete_str,
connection.get("session"),
ns)
ns,
on_error)