Error: got Future <Future pending> attached to a different loop when
thlengane opened this issue · 1 comments
Hi
I am getting the error "got Future attached to a different loop" when I try to launch an app or start WDA services. What is it that I could be missing?
user@user-machine:~$ inxi -Fz
System:
Kernel: 6.9.9 x86_64 bits: 64 Desktop: Cinnamon 6.0.4
Distro: Linux Mint 21.3 Virginia
user@user-machine:~$ pip3 list | grep -E "pymobiledevice3|tidevice3"
pymobiledevice3 4.11.9
tidevice3 0.11.3
user@user-machine:~$ sudo t3 tunneld
INFO: Started server process [184604]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:5555 (Press CTRL+C to quit)
2024-07-17 10:23:46 user-machine pymobiledevice3.cli.remote[184613] INFO tunnel created
INFO: 127.0.0.1:53406 - "GET / HTTP/1.1" 200 OK
user@user-machine:~$ t3 list
Identifier DeviceName ProductType ProductVersion ConnectionType
00008030-000979922612202E USER’s iPad iPad12,2 17.2 USB
user@user-machine:~$ t3 runwda --bundle-id com.poc.app.WebDriverAgentRunner.xctrunner
Exception in thread Thread-2 (xcuitest):
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/tidevice3/cli/runwda.py", line 54, in xcuitest
XCUITestService(service_provider).run(bundle_id)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/dvt/testmanaged/xcuitest.py", line 52, in run
self.setup_xcuitest(bundle_id, xctest_path, xctest_configuration)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/dvt/testmanaged/xcuitest.py", line 166, in setup_xcuitest
for name in afc.listdir("/tmp"):
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/parameter_decorators/common.py", line 28, in new_f
return f(*ba.args, **ba.kwargs)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/afc.py", line 383, in listdir
data = self._do_operation(afc_opcode_t.READ_DIR, afc_read_dir_req_t.build({'filename': filename}))
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/afc.py", line 593, in _do_operation
self._dispatch_packet(opcode, data)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/afc.py", line 573, in _dispatch_packet
self.service.sendall(header + data)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/service_connection.py", line 123, in sendall
self.socket.sendall(data)
OSError: [Errno 9] Bad file descriptor
unhandled exception: Task <Task pending name='Task-2' coro=<RemoteServiceDiscoveryService.close() running at /home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/remote/remote_service_discovery.py:121> cb=[_run_until_complete_cb() at /usr/lib/python3.10/asyncio/base_events.py:184]> got Future attached to a different loop
Traceback (most recent call last):
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/tidevice3/main.py", line 20, in main
cli(auto_envvar_prefix='T3')
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/tidevice3/cli/cli_common.py", line 54, in new_func
with service_provider:
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/tidevice3/api.py", line 96, in exit
get_asyncio_loop().run_until_complete(self.close())
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/remote/remote_service_discovery.py", line 121, in close
await self.service.close()
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/remote/remotexpc.py", line 62, in close
await self._writer.wait_closed()
File "/usr/lib/python3.10/asyncio/streams.py", line 343, in wait_closed
await self._protocol._get_close_waiter(self)
RuntimeError: Task <Task pending name='Task-2' coro=<RemoteServiceDiscoveryService.close() running at /home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/remote/remote_service_discovery.py:121> cb=[_run_until_complete_cb() at /usr/lib/python3.10/asyncio/base_events.py:184]> got Future attached to a different loop
user@user-machine:~$ t3 app launch com.apple.iMovie
^Cunhandled exception: Task <Task pending name='Task-2' coro=<RemoteServiceDiscoveryService.close() running at /home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/remote/remote_service_discovery.py:121> cb=[_run_until_complete_cb() at /usr/lib/python3.10/asyncio/base_events.py:184]> got Future attached to a different loop
Traceback (most recent call last):
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/remote_server.py", line 466, in _recv_packet_fragments
message = self.channel_messages[channel].get()
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/remote_server.py", line 294, in get
return self._messages.get_nowait()
File "/usr/lib/python3.10/queue.py", line 199, in get_nowait
return self.get(block=False)
File "/usr/lib/python3.10/queue.py", line 168, in get
raise Empty
_queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/tidevice3/cli/cli_common.py", line 55, in new_func
return ctx.invoke(func, service_provider, *args, **kwargs)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/tidevice3/cli/app.py", line 73, in app_launch
pid = process_control.launch(
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/dvt/instruments/process_control.py", line 72, in launch
result = self._channel.receive_plist()
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/remote_server.py", line 261, in receive_plist
return self._service.recv_plist(self)[0]
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/remote_server.py", line 435, in recv_plist
data, aux = self.recv_message(channel)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/remote_server.py", line 447, in recv_message
packet_stream = self._recv_packet_fragments(channel)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/services/remote_server.py", line 471, in _recv_packet_fragments
data = self.service.recvall(dtx_message_header_struct.sizeof())
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/service_connection.py", line 138, in recvall
chunk = self.recv(size - len(data))
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/service_connection.py", line 119, in recv
return self.socket.recv(length)
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/tidevice3/main.py", line 20, in main
cli(auto_envvar_prefix='T3')
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/tidevice3/cli/cli_common.py", line 54, in new_func
with service_provider:
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/tidevice3/api.py", line 96, in exit
get_asyncio_loop().run_until_complete(self.close())
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/remote/remote_service_discovery.py", line 121, in close
await self.service.close()
File "/home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/remote/remotexpc.py", line 62, in close
await self._writer.wait_closed()
File "/usr/lib/python3.10/asyncio/streams.py", line 343, in wait_closed
await self._protocol._get_close_waiter(self)
RuntimeError: Task <Task pending name='Task-2' coro=<RemoteServiceDiscoveryService.close() running at /home/user/.local/pipx/venvs/tidevice3/lib/python3.10/site-packages/pymobiledevice3/remote/remote_service_discovery.py:121> cb=[_run_until_complete_cb() at /usr/lib/python3.10/asyncio/base_events.py:184]> got Future attached to a different loop
Get similar problem under macOS 13.0.1 and Ubuntu 20.04.6,
for device ios 17.4.1
Identifier DeviceName ProductType ProductVersion ConnectionType
00008110-00010D363A38801E iPhone13 iPhone14,5 17.4.1 USB
pymobiledevice3 4.10.14
tidevice3 0.11.3
with command
t3 app launch tv.danmaku.bilianime, or, t3 appp ps json
unhandled exception: Task <Task pending name='Task-2' coro=<RemoteServiceDiscoveryService.close() running at /Users/sician/Library/Python/3.9/lib/python/site-packages/pymobiledevice3/remote/remote_service_discovery.py:121> cb=[_run_until_complete_cb() at /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py:184]> got Future attached to a different loop
Traceback (most recent call last):
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/tidevice3/main.py", line 20, in main
cli(auto_envvar_prefix='T3')
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/tidevice3/cli/cli_common.py", line 55, in new_func
return ctx.invoke(func, service_provider, *args, **kwargs)
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/tidevice3/api.py", line 96, in exit
get_asyncio_loop().run_until_complete(self.close())
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/pymobiledevice3/remote/remote_service_discovery.py", line 121, in close
await self.service.close()
File "/Users/sician/Library/Python/3.9/lib/python/site-packages/pymobiledevice3/remote/remotexpc.py", line 62, in close
await self._writer.wait_closed()
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/streams.py", line 359, in wait_closed
await self._protocol._get_close_waiter(self)
RuntimeError: Task <Task pending name='Task-2' coro=<RemoteServiceDiscoveryService.close() running at /Users/sician/Library/Python/3.9/lib/python/site-packages/pymobiledevice3/remote/remote_service_discovery.py:121> cb=[_run_until_complete_cb() at /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py:184]> got Future attached to a different loop