I’ve trying to use asyncio
with Google Calendar API for quite some days now (It’s mainly for a service file that I’ll be using with my gtk widget setup to fetch events). I just have a minor issue with this. My setup looks something like this: “`
Imports:
from gi.events import GLibEventLoopPolicy from asyncio import sleep, set_event_loop_policy
Inside GoogleCal(GObject.Object) class:
async def _fetch_events(self): try: <do something> except HttpError: <handle error>
async def _fetch_calns(self): While True: try: <do something> self._loop.create_task(self._fetch_events()) except HttpError: <handle error> except ClosedError: break
async def _init_sync(self, date): <raise ClosedError if year’s not the same> self._loop.create_task(self._fetch_calns()) <load offline resources.json in meantime>
def set_date(self, date): self._loop.create_task(self._init_sync(date))
def init(self): super().init()
policy = GLibEventLoopPolicy() set_event_loop_policy(policy) self._loop = policy.get_event_loop()
“`
But when ClosedError
hits it shows Task exception was never retrieved future: <Task finished name='Task-6', coro=<GoogleCal._init_sync() done, ...> exception=ClosedError>
How can I fix this?
submitted by /u/Meta_Storm_99
[link] [comments]
r/learnpython I’ve trying to use asyncio with Google Calendar API for quite some days now (It’s mainly for a service file that I’ll be using with my gtk widget setup to fetch events). I just have a minor issue with this. My setup looks something like this: “` Imports: from gi.events import GLibEventLoopPolicy from asyncio import sleep, set_event_loop_policy Inside GoogleCal(GObject.Object) class: async def _fetch_events(self): try: <do something> except HttpError: <handle error> async def _fetch_calns(self): While True: try: <do something> self._loop.create_task(self._fetch_events()) except HttpError: <handle error> except ClosedError: break async def _init_sync(self, date): <raise ClosedError if year’s not the same> self._loop.create_task(self._fetch_calns()) <load offline resources.json in meantime> def set_date(self, date): self._loop.create_task(self._init_sync(date)) def init(self): super().init() policy = GLibEventLoopPolicy() set_event_loop_policy(policy) self._loop = policy.get_event_loop() “` But when ClosedError hits it shows Task exception was never retrieved future: <Task finished name=’Task-6′, coro=<GoogleCal._init_sync() done, …> exception=ClosedError> How can I fix this? submitted by /u/Meta_Storm_99 [link] [comments]
I’ve trying to use asyncio
with Google Calendar API for quite some days now (It’s mainly for a service file that I’ll be using with my gtk widget setup to fetch events). I just have a minor issue with this. My setup looks something like this: “`
Imports:
from gi.events import GLibEventLoopPolicy from asyncio import sleep, set_event_loop_policy
Inside GoogleCal(GObject.Object) class:
async def _fetch_events(self): try: <do something> except HttpError: <handle error>
async def _fetch_calns(self): While True: try: <do something> self._loop.create_task(self._fetch_events()) except HttpError: <handle error> except ClosedError: break
async def _init_sync(self, date): <raise ClosedError if year’s not the same> self._loop.create_task(self._fetch_calns()) <load offline resources.json in meantime>
def set_date(self, date): self._loop.create_task(self._init_sync(date))
def init(self): super().init()
policy = GLibEventLoopPolicy() set_event_loop_policy(policy) self._loop = policy.get_event_loop()
“`
But when ClosedError
hits it shows Task exception was never retrieved future: <Task finished name='Task-6', coro=<GoogleCal._init_sync() done, ...> exception=ClosedError>
How can I fix this?
submitted by /u/Meta_Storm_99
[link] [comments]