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

Error: Cannot run the event loop while another loop is running when using async_notify_multiple_devices #348

Open
tranvannhat opened this issue Jul 8, 2024 · 1 comment

Comments

@tranvannhat
Copy link

tranvannhat commented Jul 8, 2024

fastapi = "^0.111.0"
pyfcm = "^2.0.4"
I using async_notify_multiple_devices and get error: Cannot run the event loop while another loop is running

@vmtniichov
Copy link

from pyfcm.async_fcm import fetch_tasks
from pyfcm.baseapi import BaseAPI


class FCMNotification(BaseAPI):

    async def send_async_request(self, params_list, timeout=5):
        payloads = [self.parse_payload(**params) for params in params_list]
        responses = await fetch_tasks(
            end_point=self.FCM_END_POINT,
            headers=self.request_headers(),
            payloads=payloads,
            timeout=timeout,
        )

        return responses

Create a new FCM class inherit from the BaseAPI and replace async_notify_multiple_devices usages with send_async_request will resolve your issue

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

No branches or pull requests

2 participants