You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support creating a ProcessInterface without a running loop in 3.8 and 3.9 #6858
dask-jobqueue creates a ProcessInterface as a test outside of a running event loop, this is supported on 3.10 thanks to the asyncio.mixins._LoopBoundMixin, this is not supported on 3.8 and 3.9 because asyncio.Lock and asyncio.Event call the deprecated asyncio.get_event_loop()
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:56:21)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from distributed.deploy.spec import ProcessInterface
>>> ProcessInterface()
<distributed.deploy.spec.ProcessInterface: status=created>
>>> async def noop(): pass
...
>>> import asyncio
>>> asyncio.run(noop())
>>> ProcessInterface()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/graingert/projects/distributed/distributed/deploy/spec.py", line 56, in __init__
self.lock = asyncio.Lock()
File "/home/graingert/anaconda3/envs/dask-distributed-39/lib/python3.9/asyncio/locks.py", line 81, in __init__
self._loop = events.get_event_loop()
File "/home/graingert/anaconda3/envs/dask-distributed-39/lib/python3.9/asyncio/events.py", line 642, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'MainThread'.
>>>
What you expected to happen:
from distributed.deploy.spec import ProcessInterface
async def noop(): pass
ProcessInterface() # no deprecation warning
asyncio.run(noop)
ProcessInterface() # no deprecation warning
one option is to backport asyncio.Lock and asyncio.Event from 3.10 similar to distributed.actor._LateLoopEvent
the other option is to use cached_property:
changed the title [-]Support creating a `class ProcessInterface` without a running loop in 3.8 and 3.9[/-][+]Support creating a `ProcessInterface` without a running loop in 3.8 and 3.9[/+]on Aug 9, 2022
Activity
graingert commentedon Aug 9, 2022
one option is to backport
asyncio.Lockandasyncio.Eventfrom 3.10 similar todistributed.actor._LateLoopEventthe other option is to use cached_property:
[-]Support creating a `class ProcessInterface` without a running loop in 3.8 and 3.9[/-][+]Support creating a `ProcessInterface` without a running loop in 3.8 and 3.9[/+]