Skip to content

_IocpProactor._poll might need to account for _unregistered #90

@stat1c-void

Description

@stat1c-void

Hi!

I've been hitting a problem on Windows with IocpProactor not closing.
Firstly, it seems to be solved in recent commits - when using master code the problem does not seem to appear anymore, thanks! It seems additional locking has solved it (#87).

I've asked my debugging question and described details on python forums: https://discuss.python.org/t/asyncio-iocpproactor-does-not-close/35206
Mind you, all my thoughts at the end seem to be completely wrong.

But I wonder if overridden _IocpProactor._poll is missing this code from upstream _poll?

        # Remove unregistered futures
        for ov in self._unregistered:
            self._cache.pop(ov.address, None)
        self._unregistered.clear()

https://github.com/python/cpython/blob/43a6e4fa4934fcc0cbd83f7f3dc1b23a5f79f24b/Lib/asyncio/windows_events.py#L825-L828

Because after some more debugging I expected that's the problem - items from _cache do not get evicted, they are unregistered, but hang in _cache.
Unless _unregister does not get called at all with the overridden proactor? But I think it can be called from run_forever:
https://github.com/python/cpython/blob/43a6e4fa4934fcc0cbd83f7f3dc1b23a5f79f24b/Lib/asyncio/windows_events.py#L332-L334

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions