-
Notifications
You must be signed in to change notification settings - Fork 32
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
Support for Python 3.10 #18
Comments
Ran into the same issue managed to resolve it like this as quick fix : import asyncio
import logging
from typing import Any
import aiohttp
from aiocometd.constants import ConnectionType
from aiocometd.exceptions import TransportError
from aiocometd.typing import JsonObject
from aiocometd.transports.registry import register_transport
from aiocometd.transports.base import TransportBase, Payload, Headers
LOGGER = logging.getLogger(__name__)
class UpdatedLongPollingTransport(TransportBase):
"""Long-polling type transport"""
def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)
#: semaphore to limit the number of concurrent HTTP connections to 2
self._http_semaphore = asyncio.Semaphore(2)
async def _send_final_payload(self, payload: Payload, *,
headers: Headers) -> JsonObject:
try:
session = await self._get_http_session()
async with self._http_semaphore:
response = await session.post(self._url, json=payload,
ssl=self.ssl, headers=headers,
timeout=self.request_timeout)
response_payload = await response.json(loads=self._json_loads)
headers = response.headers
except aiohttp.client_exceptions.ClientError as error:
LOGGER.warning("Failed to send payload, %s", error)
raise TransportError(str(error)) from error
response_message = await self._consume_payload(
response_payload,
headers=headers,
find_response_for=payload[0]
)
if response_message is None:
error_message = "No response message received for the " \
"first message in the payload"
LOGGER.warning(error_message)
raise TransportError(error_message)
return response_message
# In the startup of your engine
import asyncio
from aiocometd.constants import ConnectionType
from aiocometd.transports.registry import register_transport
def startup():
register_transport(ConnectionType.LONG_POLLING)(UpdatedLongPollingTransport)
loop = asyncio.get_event_loop()
loop.run_until_complete(self.salesforce_stream()) |
HI .. what the plan on making library compatible with python 3.10 ? |
@mohitmathew, I doubt there is any plan at this point. We locally forked ours to allow us to get past the version limit. |
The problem here is that aiocometd is not compatible with 3.10 and above. There is a fork called aiocometd_noloop that it is. It works for me: if sys.version_info >= (3, 10):
__import__('aiocometd_noloop')
sys.modules['aiocometd'] = sys.modules.pop('aiocometd_noloop')
print('Using aiocometd_noloop instead of aiocometd')
from aiosfstream import SalesforceStreamingClient |
Related to robertmrk/aiocometd#13 in the aiocometd dependency.
The loop parameter was removed. See last bullet of https://docs.python.org/3/whatsnew/3.10.html#removed.
The text was updated successfully, but these errors were encountered: