Open ghost opened 2 years ago
Ran into the same issue managed to resolve it like this as quick fix : Note: This will just override the existing transport class and removes the loop kwarg
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 ?
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.
Related to https://github.com/robertmrk/aiocometd/issues/13 in the aiocometd dependency.
The loop parameter was removed. See last bullet of https://docs.python.org/3/whatsnew/3.10.html#removed.