TypeError: ensure_future() takes 1 positional argument but 2 were given

How severe does this issue affect your experience of using Ray?

  • Low: It annoys or frustrates me for a moment.

I faced below error in production environment of our inference:

[Main] 8004: Error: Traceback (most recent call last):
 File "main.py", line 239, in unsubscribe_logger_job
   result_unsub = ray.get(log_actor.unsubscribe_job.remote(job_id))
 File "/usr/local/lib/python3.8/dist-packages/ray/_private/client_mode_hook.py", line 105, in wrapper
   return func(*args, **kwargs)
 File "/usr/local/lib/python3.8/dist-packages/ray/worker.py", line 1831, in get
   raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(TypeError): e[36mray::logActor.unsubscribe_job()e[39m (pid=34764, ip=10.60.65.143, repr=<tools.log_actor.logActor object at 0x7fbc9c51e5b0>)
TypeError: ensure_future() takes 1 positional argument but 2 were given

Here LogActor class is defined as below:

class LogActor:
    def __init__(self):
        self.active_jobs = []

    async def subscribe_job(self, job_id):
    	self.active_jobs.append(job_id)

    async def unsubscribe_job(self, job_id):
		if not job_id in self.active_jobs:
			return False
		self.active_jobs.remove(job_id)
		return True

	...

I could not reproduce the error again. As I getting the error in production environment, It would be helpful if anyone can help me to debug this error.

I checked the code, I think it’s due to a bug in the codebase. Will create a PR to fix it. Thanks for reporting!

It’d be great if you can provide a reproduce script so that I can verify the fix actually works.

@jjyao
Thanks for your support.

I could not reproduce that scenario in our development environment. Even, we haven’t seen that scenario again in our production environment.

My PR: [Core] Fix asyncio.ensure_future call by jjyao · Pull Request #32932 · ray-project/ray · GitHub

1 Like