Skip to content
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

aioimap: using await/async syntax #59

Merged
merged 3 commits into from Apr 15, 2021
Merged

aioimap: using await/async syntax #59

merged 3 commits into from Apr 15, 2021

Conversation

bamthomas
Copy link
Owner

as mentioned in #52 it is legit to go from @coroutine python 3.4 style to python 3.5 async/await (as python 3.5 is not even maintained)

If it is ok for everyone I will merge this next week

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 95.794% when pulling 0235f84 on async_await into c59cf4f on master.

@coveralls
Copy link

coveralls commented Apr 10, 2021

Coverage Status

Coverage decreased (-1.05%) to 95.902% when pulling 631d94f on async_await into d145aa0 on master.

@Lithimlin
Copy link

On this branch, I am getting the following Error for the Condition object:

Traceback (most recent call last):
  File ".../async-test.py", line 28, in <module>
    get_event_loop().run_until_complete(check_mailbox('IMAP_SERVER', 'IMAP_USER', 'IMAP_PASSWORD'))
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File ".../async-test.py", line 16, in check_mailbox
    await imap_client.wait_hello_from_server()
  File ".../aioimaplib/aioimaplib.py", line 686, in wait_hello_from_server
    await asyncio.wait_for(self.protocol.wait('AUTH|NONAUTH'), self.timeout)
  File "/usr/lib/python3.9/asyncio/tasks.py", line 481, in wait_for
    return fut.result()
  File ".../aioimaplib/aioimaplib.py", line 595, in wait
    with (await self.state_condition):
TypeError: object Condition can't be used in 'await' expression

@bamthomas
Copy link
Owner Author

bamthomas commented Apr 13, 2021

which python version ?

weird CI was green and it was green here but you're right the doc is saying that it should be

async with cond:
    await cond.wait()

not sure that async with... is same as with async...

I will have a look on thursday

@Lithimlin
Copy link

I'm on version 3.9, so the newest. For new projects I usually try to stick with the newest versions so I don't get confused when a feature I try to use doesn't work.

@bamthomas bamthomas merged commit 4d7b9a0 into master Apr 15, 2021
@Lithimlin
Copy link

Just wanted to let you know that in line 594, you still have with await self.state_condition: instead of async with self.state_condition:, causing a TypeError to be raised.

@Lithimlin
Copy link

With that fixed, I get the following:

Task exception was never retrieved
future: <Task finished name='Task-2' coro=<BaseEventLoop.create_connection() done, defined at /usr/lib/python3.9/asyncio/base_events.py:967> exception=gaierror(-2, 'Name or service not known')>

bamthomas added a commit that referenced this pull request Apr 15, 2021
@bamthomas
Copy link
Owner Author

It should be related to python 3.9 I guess. I will try to test with 3.9 (didn't manage to install virtualenv with it)

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.

None yet

3 participants