Skip to content

Conversation

@pablogsal
Copy link
Member

@pablogsal pablogsal commented Jan 28, 2018

@pablogsal pablogsal changed the title Add native coroutine support to bdb when stepping over line bpo-32650: Add native coroutine support to bdb when stepping over line Jan 28, 2018
@asvetlov
Copy link
Contributor

Thank you for patch but tests are needed.
You can take a look on tests from initial commit 8820c23 which had introduced generator based coroutines.
Copying generator tests but replacement generators with async defs would be easiest way I believe.

@asvetlov asvetlov self-requested a review January 28, 2018 23:10
@pablogsal
Copy link
Member Author

@asvetlov I think is more complicated as coroutines are not iterable objects. Take for example test_pdb_next_command_for_generator. Replacing def for async def in test_gen will raise TypeError on next(it).

@asvetlov
Copy link
Contributor

I did mean not literal replacement but pointing on bdb tests style and required functionality.

@pablogsal
Copy link
Member Author

@asvetlov My bad, I did not understood your comment correctly. I will try to generate the required tests. Thanks for the comments :)

@asvetlov
Copy link
Contributor

No problem.

@pablogsal
Copy link
Member Author

@asvetlov In 97a0652 you will find a proposal for test style and functionality. I am invoking the coroutines though an event loop to avoid having to manually control the state with the send attribute. Please, confirm that this is OK so I can continue adding other tests if needed.

@pablogsal
Copy link
Member Author

This is the output without this patch for comparison:

> /home/pablogsal/github/cpython/cosa.py(10)test_f()
-> await test_gen()
(Pdb) s
--Call--
> /home/pablogsal/github/cpython/cosa.py(3)test_gen()
-> async def test_gen():
(Pdb) s
> /home/pablogsal/github/cpython/cosa.py(4)test_gen()
-> await asyncio.sleep(0)
(Pdb) n
--Return--
> /home/pablogsal/github/cpython/cosa.py(4)test_gen()->None
-> await asyncio.sleep(0)
(Pdb)
--Return--
> /home/pablogsal/github/cpython/cosa.py(10)test_f()->None
-> await test_gen()
(Pdb)
--Call--
> /usr/lib/python3.6/asyncio/base_events.py(564)call_soon()
-> def call_soon(self, callback, *args):
(Pdb) s
> /usr/lib/python3.6/asyncio/base_events.py(574)call_soon()
-> self._check_closed()
(Pdb) s
--Call--
> /usr/lib/python3.6/asyncio/base_events.py(355)_check_closed()
-> def _check_closed(self):
(Pdb) c

@asvetlov
Copy link
Contributor

Looks perfect, please go ahead

@asvetlov asvetlov requested review from 1st1 and njsmith January 29, 2018 00:12
@asvetlov
Copy link
Contributor

@1st1 @njsmith you may be interesting in the PR

@1st1
Copy link
Member

1st1 commented Jan 29, 2018

Andrew, I don't use pdb myself, so if you think the change is ok please feel free to merge it.

@1st1
Copy link
Member

1st1 commented Jan 29, 2018

Keep in mind that it's better to be merged now in order for it to make it to beta1.

@pablogsal
Copy link
Member Author

pablogsal commented Jan 29, 2018

@asvetlov We can merge it now without closing the issue and implement more tests later if you are Ok with that.

@1st1 Do you think there is a better way to test this behaviour without invoking the coroutines though the event loop?

@asvetlov
Copy link
Contributor

Sounds like a plan

@1st1
Copy link
Member

1st1 commented Jan 29, 2018

You can just manually advance a coroutine a with coro.send() method.

@asvetlov
Copy link
Contributor

@pablogsal I'm going to sleep.
Please make a next PR with missing tests

@asvetlov
Copy link
Contributor

Thanks for contribution!

@miss-islington
Copy link
Contributor

Thanks @pablogsal for the PR, and @asvetlov for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 29, 2018
@bedevere-bot
Copy link

GH-5402 is a backport of this pull request to the 3.6 branch.

@1st1
Copy link
Member

1st1 commented Jan 29, 2018

Maybe you should also handle CO_ASYNC_GENERATOR flag.

@pablogsal
Copy link
Member Author

@1st1 I am adding this in #5403

asvetlov pushed a commit that referenced this pull request Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants