-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-32418: Add get_loop() method on Server, AbstractServer classes #4997
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
Changes from all commits
64b88e2
2f4b93f
d0792fd
e6f7283
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,10 @@ async def wait_closed(self): | |
"""Coroutine to wait until service is closed.""" | ||
return NotImplemented | ||
|
||
def get_loop(self): | ||
""" Get the event loop the Server object is attached to.""" | ||
return NotImplemented | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a test for make sure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @asvetlov It should raise There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oooh, my bad. |
||
|
||
|
||
class AbstractEventLoop: | ||
"""Abstract event loop.""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2865,6 +2865,19 @@ class TestCGetEventLoop(GetEventLoopTestsMixin, unittest.TestCase): | |
get_running_loop_impl = events._c_get_running_loop | ||
get_event_loop_impl = events._c_get_event_loop | ||
|
||
class TestServer(unittest.TestCase): | ||
|
||
def test_get_loop(self): | ||
loop = asyncio.new_event_loop() | ||
proto = MyProto(loop) | ||
server = loop.run_until_complete(loop.create_server(lambda: proto, '0.0.0.0', 0)) | ||
self.assertEqual(server.get_loop(), loop) | ||
loop.close() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test will leak an open server object. Add |
||
|
||
class TestAbstractServer(unittest.TestCase): | ||
|
||
def test_get_loop(self): | ||
self.assertEqual(events.AbstractServer().get_loop(), NotImplemented) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add get_loop() method to Server and AbstractServer classes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test for the method.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot find tests for Server class. Could you help me please? Or it looks like i need to write test cases for Server class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loop.create_server
returns Server objects.