Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Remove 'yield' from some request handlers (#5) (#1267)
Browse files Browse the repository at this point in the history
* Remove 'yield' from some request handlers
* Fix json notify request
  • Loading branch information
karthiknadig authored Mar 27, 2019
1 parent 7b0353d commit b65e15a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/ptvsd/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,12 @@ def pydevd_notify(self, cmd_id, args, is_json=False):
else:
seq, s = self.make_packet(cmd_id, args)
with self.lock:
os.write(self.pipe_w, s.encode('utf8'))
as_bytes = s
if not isinstance(as_bytes, bytes):
as_bytes = as_bytes.encode('utf-8')
if is_json:
os.write(self.pipe_w, ('Content-Length:%s\r\n\r\n' % (len(as_bytes),)).encode('ascii'))
os.write(self.pipe_w, as_bytes)

def pydevd_request(self, loop, cmd_id, args, is_json=False):
'''
Expand Down Expand Up @@ -1696,8 +1701,8 @@ def on_pause(self, request, args):
pydevd_request['arguments'] = {'threadId': '*'}

# Always suspend all threads.
yield self.pydevd_request(pydevd_comm.CMD_THREAD_SUSPEND,
pydevd_request, is_json=True)
self.pydevd_request(pydevd_comm.CMD_THREAD_SUSPEND,
pydevd_request, is_json=True)
self.send_response(request)

@async_handler
Expand All @@ -1711,8 +1716,8 @@ def on_continue(self, request, args):
pydevd_request['arguments'] = {'threadId': '*'}

# Always continue all threads.
yield self.pydevd_request(pydevd_comm.CMD_THREAD_RUN,
pydevd_request, is_json=True)
self.pydevd_request(pydevd_comm.CMD_THREAD_RUN,
pydevd_request, is_json=True)
self.send_response(request, allThreadsContinued=True)

@async_handler
Expand All @@ -1725,7 +1730,7 @@ def on_next(self, request, args):
pydevd_request['arguments']['threadId'] = pyd_tid
cmd_id = pydevd_comm.CMD_STEP_OVER

yield self.pydevd_request(cmd_id, pydevd_request, is_json=True)
self.pydevd_request(cmd_id, pydevd_request, is_json=True)
self.send_response(request)

@async_handler
Expand All @@ -1738,7 +1743,7 @@ def on_stepIn(self, request, args):
pydevd_request['arguments']['threadId'] = pyd_tid
cmd_id = pydevd_comm.CMD_STEP_INTO

yield self.pydevd_request(cmd_id, pydevd_request, is_json=True)
self.pydevd_request(cmd_id, pydevd_request, is_json=True)
self.send_response(request)

@async_handler
Expand All @@ -1751,7 +1756,7 @@ def on_stepOut(self, request, args):
pydevd_request['arguments']['threadId'] = pyd_tid
cmd_id = pydevd_comm.CMD_STEP_RETURN

yield self.pydevd_request(cmd_id, pydevd_request, is_json=True)
self.pydevd_request(cmd_id, pydevd_request, is_json=True)
self.send_response(request)

@async_handler
Expand Down

0 comments on commit b65e15a

Please sign in to comment.