Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def connection(self):
"""Return a connection to the server, establishing it if necessary."""
if self._connection is None:
try:
self._connection = aioimaplib.IMAP4_SSL(self._server, self._port)
await self._connection.wait_hello_from_server()
await self._connection.login(self._user, self._password)
await self._connection.select(self._folder)
self._does_push = self._connection.has_capability("IDLE")
except (aioimaplib.AioImapException, asyncio.TimeoutError):
self._connection = None
return self._connection
async def connection(self):
"""Return a connection to the server, establishing it if necessary."""
import aioimaplib
if self._connection is None:
try:
self._connection = aioimaplib.IMAP4_SSL(
self._server, self._port)
await self._connection.wait_hello_from_server()
await self._connection.login(self._user, self._password)
await self._connection.select(self._folder)
self._does_push = self._connection.has_capability('IDLE')
except (aioimaplib.AioImapException, asyncio.TimeoutError):
self._connection = None
return self._connection