Skip to content

Conversation

@DVNghiem
Copy link
Contributor

This pull request includes a minor change to the serve_forever method in rloop/server.py. The change replaces the use of self._loop.create_future() with self.get_loop().create_future() to ensure compatibility with the loop retrieval method.

import asyncio
import rloop
import traceback

async def start_server(host: str, port: int):
    server = await asyncio.start_server(
        lambda r, w: asyncio.Protocol().connection_made(w), host, port
    )
    try:
        async with server:
            await server.serve_forever()
    except Exception as e:
        traceback.print_exc()

if __name__ == "__main__":
    loop = rloop.new_event_loop()
    loop.run_until_complete(start_server("0.0.0.0", 8888))

Exception is:
line 30, in serve_forever self._sff = self._loop.create_future() ^^^^^^^^^^ AttributeError: 'Server' object has no attribute '_loop'

Copy link
Owner

@gi0baro gi0baro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution ❤️
I'd say even using the "private" interface (self._inner._loop) is fine in this case.

@DVNghiem
Copy link
Contributor Author

Thank you so much! I will update accordingly.

@gi0baro gi0baro merged commit 3616865 into gi0baro:master May 31, 2025
13 checks passed
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.

2 participants