-
Notifications
You must be signed in to change notification settings - Fork 50
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
Unexpected keyword argument 'loop' under Python 3.10 #162
Comments
Looking through some of the other open issues, it does not appear Pydle supports Python 3.10 at present (Ref #161, #142) as a few places call I can't say if this issue is related to that or not, but it might be a contributing factor. Can you provide more information about your environment and the context this code is in to assist in diagnosis? |
Dug into this a bit.
The combination of these two issues leads to an easy footgun demonstrated by this sample code (using #165 's new feature, although not relevant to this issue) : from pydle import Client
import asyncio
client = Client("MyBot", realname='My Bot')
@client.event
async def on_connect(self):
await self.join('#bottest')
@client.event
async def on_message(self, target, source, message):
# don't respond to our own messages, as this leads to a positive feedback loop
if source != self.nickname:
await self.message(target, message)
async def main():
await client.connect('localhost', tls=True, tls_verify=False)
await client.handle_forever()
if __name__ == "__main__":
asyncio.run(main()) Pydle tries to run on a different event loop than it was called under. RuntimeError: Task <Task pending name='Task-1' coro=<main() running at test.py:20> cb=[_run_until_complete_cb() at /usr/lib/python3.8/asyncio/base_events.py:184]> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.8/asyncio/futures.py:360]> attached to a different loop The currently "correct" version of the above is: from pydle import Client
import asyncio
loop = asyncio.get_event_loop()
client = Client("MyBot", realname='My Bot', loop=loop)
@client.event
async def on_connect(self):
await self.join('#bottest')
@client.event
async def on_message(self, target, source, message):
# don't respond to our own messages, as this leads to a positive feedback loop
if source != self.nickname:
await self.message(target, message)
async def main():
await client.connect('localhost', tls=True, tls_verify=False)
await client.handle_forever()
if __name__ == "__main__":
loop.run_until_complete(main()) The real fix here would be to remove Pydle's internal handling of the event loop object entirely, and instead depend upon the fact that pydle's coroutines will be awaited by downstream code - from a valid event loop. Doing so would be a breaking change by semver, as it changes the public api in a backward-incompatible way. |
Implements suggestions in shizmob#162 (comment) to remove Pydle's internal handling of the event loop object entirely.
Implements suggestions in shizmob#162 (comment) to remove Pydle's internal handling of the event loop object entirely.
Implements suggestions in shizmob#162 (comment) to remove Pydle's internal handling of the event loop object entirely.
Is this still a problem on 3.11, or is upgrading Python a potential solution? |
Pydle is also broken on 3.11. Upgrading is not a fix. See #180 for the current discussion on various potential fixes. I'll also note for the record that 3.11 removed |
shizmob/pydle#51 (comment) shizmob/pydle#162 Add jaraco.collections, jaraco.functools, jaraco.logging, jaraco.stream, jaraco.text, and tempora as secondary requirements for irc Add autocommand and jaraco.classes as tertiary requirements for irc
https://build.opensuse.org/request/show/1067570 by user dgarcia + dimstar_suse - Delete python-pydle-poetry-syntax.patch - Skip python 310 and python 311, pydle doesn't python 3.10 gh#shizmob/pydle#162, There's a WIP PR but looks like it's not good enough yet to be applied gh#shizmob/pydle#180 - Update to version 1.0.1 * [Docs] Document Dropping of 3.5 by @Rixxan in #179 * Adjust python version inequality string for Poetry by @txtsd in #182 * bump version to 1.0.1 by @theunkn0wn1 in #183
The text was updated successfully, but these errors were encountered: