micro-fan / aiozk

Asyncio client for zookeeper
MIT License
49 stars 20 forks source link

Cancel Heartbeat when closing the session #46

Closed nonsleepr closed 3 years ago

nonsleepr commented 4 years ago

Fixes the following error message:

Task was destroyed but it is pending!
task: <Task pending name='Task-179' coro=<Session.heartbeat() running at .../aiozk/session.py:240> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x10d01a340>()]>>
rhdxmr commented 4 years ago

Hi @nonsleepr

I think that your patch does not cancel the already running .heartbeat() task. So that 'Task was destroyed but it is pending!' message would keep appearing.

self.heartbeat_handle.cancel() only calls .cancel() method of TimerHandle object relevant with .create_heartbeat() method. But it would already been called and there would exist heartbeat() task.

rhdxmr commented 3 years ago

Hello @cybergrind

I fixed this PR and added a test for it.

@nonsleepr Since that this PR allows edits from maintainer, I was able to add some commits, rebase and push them to your PR branch. Thank you.

cybergrind commented 3 years ago

@rhdxmr great! will check and merge soon

cybergrind commented 3 years ago

@nonsleepr / @rhdxmr thank you, landed in 0.28.0