diff --git a/src/trio/_core/_io_epoll.py b/src/trio/_core/_io_epoll.py index b21d8c4718..1f4ae49f7a 100644 --- a/src/trio/_core/_io_epoll.py +++ b/src/trio/_core/_io_epoll.py @@ -200,7 +200,9 @@ class _EpollStatistics: @attrs.define(eq=False, hash=False) class EpollIOManager: - _epoll: select.epoll = attrs.Factory(select.epoll) + # Using lambda here because otherwise crash on import with gevent monkey patching + # See https://github.com/python-trio/trio/issues/2848 + _epoll: select.epoll = attrs.Factory(lambda: select.epoll()) # {fd: EpollWaiters} _registered: defaultdict[int, EpollWaiters] = attrs.Factory( lambda: defaultdict(EpollWaiters)